- Posted by dan on March 18, 2013
Following on from the Single Responsibility Principle, we have the second of the SOLID Principle the Open Closed Principle or OCP.
The Open Closed Principle states that classes should be open for extension but closed for modification. It has a long history originally coming for Bertrand Meyer in his book on Object Orientated software construction. In his book he tended to use a base class that base functionality that was then modified by inheritance. Nowadays we tend to use interfaces as the base abstraction so we can completely change behaviour by swapping out any classes implementation.