The Open Closed Principle in 5 minutes.

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.

blog comments powered by Disqus



The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2014