Open–closed principle

In object-oriented programming, the open–closed principle (OCP) states "software entities (classes, modules, functions, etc.)

should be open for extension, but closed for modification";[1] that is, such an entity can allow its behaviour to be extended without modifying its source code.

Both ways use generalizations (for instance, inheritance or delegate functions) to resolve the apparent dilemma, but the goals, techniques, and results are different.

Bertrand Meyer is generally credited for having originated the term open–closed principle,[2] which appeared in his 1988 book Object-Oriented Software Construction.

In 2001, Craig Larman related the open–closed principle to the pattern by Alistair Cockburn called Protected Variations, and to the David Parnas discussion of information hiding.

Portrait of Bertrand Meyer
The open-closed principle was introduced by Bertrand Meyer .