Open closed principle

From CSSEMediaWiki
Revision as of 02:51, 20 August 2008 by Warwick Irwin (Talk | contribs)
Jump to: navigation, search

The Open closed principle states "software entities (classes, modules, functions, etc.) should be open for extension, but closed for modification" as Dr. Bertrand Meyer said. That means (in an ideal way...) you should never need to change existing code or classes.

So the idea was that once completed, the implementation of a class could only be modified to correct errors. So if you want to add new or changed features/functionalities, you would need to create a different class. That class could reuse coding from the original class through inheritance. The derived subclass might or might not have the same interface as the original class.

This also prevents you from introducing new bugs in an existing code.

See also

Personal tools