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");
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();
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"