- Back to Home »
- Open Closed Principle
Posted by : Sushanth
Thursday, 17 December 2015
Software entities like classes, modules and functions should be open for extension but closed for modifications.
Open for Extension:
The behavior of the module can be extended. We can make the module behave in NEW and DIFFERENT ways as the requirements of the application change.
The behavior of the module can be extended. We can make the module behave in NEW and DIFFERENT ways as the requirements of the application change.
Closed for Modification:
The source code of such module is INVIOLATE. No one is allowed to make source code changes to it.
The source code of such module is INVIOLATE. No one is allowed to make source code changes to it.
The Client class depends directly on the Server class. Extending Server implementations is difficult and further changes may introduce complexity in code maintainability.
The Client class now depends on an abstraction of the Service by the Service Base Class. We can extend further implementation from this abstraction.