Design Patterns Java - Template method Php

1) What have at the beginning?

Let's imagine class "ClassA" which has method "doSomething"


public class ClassA
{
    public void doSomething(boolean doStep2)
    {
        System.out.println("doing step one");
        if (doStep2)
        {
            System.out.println("doing step two");
        }
        System.out.println("doing step three");
    }
}

public class Client
{
    public static void main(String[] args)
    {
        ClassA classA = new ClassA();
        classA.doSomething(true);
    }
}




Actually "doSomething" implement some code which can be divided into steps(1,2,3)

The second step is optional depending of "doStep2" parameter(but it's irrelevant for idea of this pattern)

2) What want we do?

We want to change step 3.

So let's create new class "ClassB"