Posted on April 11, 2016
Decreasing time to market is often why many teams adopt Agile.
But realizing this value requires discipline in development processes, as well as in development techniques.
In order to release small, incremental pieces of functionality often, your software must be easily extensible.
Following the Open/Closed Principle (OCP) is one of the best ways to ensure that you can easily and quickly extend your software with new functionality while maximizing the value of Agile.
by Doug Klugh
What is the Open/Closed Principle?OCP was defined in 1988 by Bertrand Meyer in his book Object Oriented Software Construction. The principle states that “software entities (classes, modules, functions, etc.) should be open for extension, but closed for modification”1. Using this principle, a developer can extend the behavior of an entity without modifying its source code. This relies on using inheritance and polymorphism by extending base classes and/or interfaces.
By applying OCP, software is made to be far more extensible than it would be otherwise. Adding new functionality to software that was built using OCP will be relatively quick and easy. And this is exactly what you need when following Agile development practices. In an attempt to deliver new functionality within a short iteration, the last thing you need is to deal with code that is tightly coupled. Not only does it make it difficult to extend, but it makes it much more likely to introduce new bugs.
SOLID PrinciplesOCP is part of the SOLID principles of object-oriented programming and design, as coined by Uncle Bob Martin in the early 2000s. The Open/Closed Principle is often used in conjunction with the other 4 SOLID principles: Single Responsibility, Liskov Substitution, Interface Segregation, and Dependency Inversion. Together these principles help to promote highly cohesive, loosely coupled software that is easy to extend and easy to maintain.
ConclusionAgile is all about being… well, agile. And to be agile, you need to be quick and responsive. If your code is tightly coupled and difficult to extend, your team will spend a lot more time implementing features than it needs. Following disciplined software engineering principles takes more time than not following them (in the short term). But over a slightly longer period of time, your team will be spend much more time extending software and fixing bugs than if it had done things the right way; the “right way” being applying proven engineering principles, such the Open/Closed Principle. Being successful at Agile requires much more than following an Agile process. Your code must also be agile. And one of the best ways to make your code agile is through OCP.
1Meyer, Bertrand (1988). Object-Oriented Software Construction. Prentice Hall. ISBN 0-13-629049-3.