Design Patterns Java - Strategy Php

1) What have we got at the beginning?

Let's imagine that we have one class "Context"

And two methods "doA" and "doB"


public class Context
{
    public void doA()
    {
        System.out.println("DoingA version1");
    }

    public void doB()
    {
        System.out.println("DoingB version1");
    }
}




2) Assumptions?

Yes, we often want to change behaviour of method "doA" and "doB" in application

What can we do?

We can inherit from class "Context" let's see this in example: