Principles Patterns Follow: Open-Closed

Bertrand Meyer (1988), based on an idea put forth earlier by Ivar Jacobsen, said, “Software entities (classes, modules, functions, etc.) should be open for extension, but closed to modification.”

What does this mean? It means that one aspect of strong design is that it allows new functions, features, behaviors, etc., to be added to a system in such a way that the previously existing code does not have to be altered.

Most experienced developers will tell you they would much prefer to make something new rather than change something old. This is because they have experienced both things and have found that making new things is less difficult, less dangerous, less time consuming, and, in general, is something they feel more confident about doing.

How can this principle be achieved? You can make a system open-closed in many different ways, depending on what you want to be able to add later by cleanly plugging in a new entity. The entity can be anything: a class, a method, a delegate, a mix-in, etc.

Each design pattern follows open-closed in a different way, about a different thing or set of things. They are various examples of componentization.

Understanding this is an interesting way to distinguish each pattern from the others. We will examine this aspect of each pattern as we explore it.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset