Open/closed principle

The Open - Closed Principle ( " Open - Closed Principle ", in short OCP) is a principle in object-oriented software design. It focuses on the extensibility of existing software.

Bertrand Meyer describes the Open - Closed Principle by:

"Modules Should Be Both open ( for extension ) and closed ( for modification ). "

"Modules should be both open ( for extensions), and closed ( for modifications ). "

With modules here are meant software units in which it can be both for modules and classes, methods, etc..

An expansion in terms of the open- closed principle is for example the inheritance. This changes the behavior of the existing unit does not, however, extend the unit to provide added functionality or data. Overridden methods also do not change the behavior of the base class, but only the derived class. If you follow beyond the Liskovschen substitution principle, even overridden methods do not change the behavior, but only the algorithms.

621427
de