![]() ![]() Martin in his articles about the SOLID principles or Joshua Bloch in his book Effective Java, inheritance introduces tight coupling if the subclasses depend on implementation details of their parent class. When a descendant class is defined, there is no need to change the original or to disturb its clients.”īut as we’ve learned over the years and as other authors explained in great details, e.g., Robert C. But it is also open, since any new class may use it as parent, adding new features. “A class is closed, since it may be compiled, stored in a library, baselined, and used by client classes. Unfortunately, Bertrand Mayer proposes to use inheritance to achieve this goal: ![]() That prevents situations in which a change to one of your classes also requires you to adapt all depending classes. It tells you to write your code so that you will be able to add new functionality without changing the existing code. The general idea of this principle is great. “Software entities (classes, modules, functions, etc.) should be open for extension, but closed for modification.” He explained the Open/Closed Principle as: But he wasn’t the first one who defined it. Bertrand Meyer wrote about it in 1988 in his book Object-Oriented Software Construction. Martin considered this principle as the “the most important principle of object-oriented design”.
0 Comments
Leave a Reply. |