The Open-Closed Principle

Software clearly needs to be extensible. However, making changes to software runs the risk of introducing problems. This dilemma led Bertrand Meyer to propose the open-closed principle.[1] To paraphrase this principle, the modules, methods, and classes should be open for extension, while closed for modification.[2] In other words, we must design our software so that we can extend the capabilities of our software without changing it.

[1] Meyer, B., Object-Oriented Software Construction, Upper Saddle River, N.J.: Prentice Hall, 1997, p. 57.

[2] See this book's Web site for a link to “The Open-Closed Principle,” an excellent article by Robert C. Martin. Go to http://www.netobjectives.com/dpexplained.

As contradictory as this may sound at first, you have already seen examples of it. In the Bridge pattern, for instance, it is quite possible to add new implementations (that is, to extend the software) without changing any of the existing classes.

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

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