SOLID Class Design: The Open Closed Principle — Tom Dalling
This is part two of a five part series about SOLID class design principles by Robert C. Martin. The SOLID principles focus on achieving code that is maintainable, robust, and reusable. In this post, I will discuss the Open Closed Principle. The Open Closed Principle (OCP): You should be able to extend a classes behavior, without modifying it. The OCP is sometimes alternatively defined as: A class should be open to extension, but closed to modification. Robert Martin sums up the rationale for the OCP like this: “When a single change to a program results in a cascade of changes to dependent modules, that program exhibits the undesirable attributes that we have come to associate with ‘bad’ design. The program becomes fragile, rigid, unpredictable and unreusable. The open-closed principle attacks this in a very straightforward way. It says that you should design modules that never change. When requirements change, you extend the behavior of such modules by adding new code, not by changing
This is part two of a five part series about SOLID class design principles by Robert C. Martin . The SOLID principles focus on achieving code that is maintainable, robust, and reusable. In this post, I will discuss the Open Closed Principle. The Open Closed Principle (OCP) : You should be able to extend a classes behavior, without modifying it . The OCP is sometimes alternatively defined as: A class should be open to extension, but closed to modification. Robert Martin sums up the rationale for the OCP like this: “When a single change to a program results in a cascade of changes to dependent m
Explore this link on the map →related reading
- SOLID Design Principles Explained: Building Better Software Architecture | DigitalOceandigitalocean.com
- SOLID Design Principles Explained- Stackifystackify.com
- SOLID Class Design: The Liskov Substitution Principle — Tom Dallingtomdalling.com
- artima - Josh Bloch on Designartima.com
- Malleable software: Restoring user agency in a world of locked-down appsinkandswitch.com
- Lab 1: Simulation I - CS2030S Programming Methodology IInus-cs2030s.github.io
- Repeat yourself, do more than one thing, and... — programming is terribleprogrammingisterrible.com
- Clean Architecture: Component Cohesion Principles | by Rebeca Mora | Mediummedium.com
- 14. Polymorphism - CS2030S Programming Methodology IInus-cs2030s.github.io
- Design Patternsrefactoring.guru
- LEAP 71 | PicoGK.org Blogpicogk.org
- Lab 2: Simulation 2 - CS2030S Programming Methodology IInus-cs2030s.github.io