Bertrand Meyer is mainly known as the founder of the term Openness / Closure Principle, which appeared in 1988 in his book Object-Oriented Software Construction. The idea was that once developed, a class implementation further only requires error correction, and new or modified functions require the creation of a new class. This new class can reuse the source class code through the inheritance mechanism. A derived subclass may or may not implement the interface of the source class.
That is, it turns out if we create, for example, a class Человек who has say methods поесть , поспать , попить . Then we will say in time we need to create a class Работник with methods - работать , получать зарплату and we need another method общаться , so what happens is that we cannot add this method общаться person, because it violates the principles of SOLID? But can we add it to the class Работник or any other Человека that is inherited by Человека ? ...
But this is incorrect? ... We can simply forget to add something to the base class, but after that it is impossible to modify it, but only to supplement and redefine the base class?
This principle will generate many unnecessary classes that inherit the base.
From Wikipedia:
Solid - principles, when applied together, are designed to increase the likelihood that a programmer will create a system that will be easy to maintain and expand over time [3]. SOLID principles are guidelines that can be applied while working on software to remove code smells by instructing a programmer to refactor the source code until it is clearly legible and extensible. It is part of an overall strategy for agile and adaptive development.
But this principle contradicts the concept (legibly written code and extensibility). Ie, if we already have a lot of created objects 'Man', and in the project we want them to now be able to communicate, after adding this method to another class, we must create all our objects on the basis of another class.
Ie according to the logic, according to the concept, according to common sense (in order not to rewrite the code) .. addition must be made in the class 'person'. + we get the opportunity to create people both having communication and those who cannot communicate - but this is a mistake in the design of the project code.
Человек общительныйwith the method ofОбщаться, which will be a descendant of the class ofЧеловекand already inherit from it theРаботника. - u_mulderЧеловекin the project, and you want to add the abilityобщатьсяin the middle of the project, this may be a mistake in the initial design. - VladD