Design Patterns Java - Bridge Php

1) What have we at the beginning?

At the beginning we have some class called "ClassA". Which defines one method "doA".

Implementation takes place in non public method: "doStep1", "doStep2", "doStep3"


public class ClassA
{
    public void doA()
    {
        doStep1();
        doStep2();
        doStep3();
    }

    protected void doStep1()
    {
        System.out.println("ClassA doing step 1");
    }

    protected void doStep2()
    {
        System.out.println("ClassA doing step 2");
    }

    protected void doStep3()
    {
        System.out.println("ClassA doing step 3");
    }

}




2) What are new requirements ?

It's turned out that we have a new requirements. In some cases we need to change implementation of individual steps.

3) What do we do?

We are creating subclass and change implementation of particular steps.