Open/Closed Principle (EN)

Concept

Principle stating that software should be open for extension but closed for modification

Architecture

classDiagram   class Shape {     +area(): double   }   class Rectangle {     -width: double     -height: double     +area(): double   }   class Circle {     -radius: double     +area(): double   }   Shape <|-- Rectangle   Shape <|-- Circle 

In Context

  • Typically used together with Dependency Inversion Principle
  • Related to: SOLID principles, Abstraction, Polymorphism
  • Example use: Extending a graphics library with new shapes without modifying the existing Shape class
Quelle: AI Generated