Open/Closed Principle
OCP
Kind: principle
Layer: Structural Core
Aliases: OCP, Open-Closed Principle
Record: architecture:open-closed
Severity: recommended
Scope: class, module, component
Canonical: Ontology
A design rule that a module gains new behavior by adding code at an extension point, leaving its existing code unchanged.
Listed in Architecture principles, after Dependency Inversion Principle (DIP) and before Liskov Substitution Principle (LSP).
Requires
Reinforces
Enables
Conflicts with
In tension with
Tensions
Contracts
Violated by
Refactored by
Severity
Category
Enforced by
- rules/eslint/closure-barrel-must-be-glob.eslint.rule.ts
- rules/eslint/require-self-registration.eslint.rule.ts
Reinforced by
- Dynamic Dispatch
- Runtime Extensibility
- Polymorphism
- Command Pattern
- State Pattern
- Chain of Responsibility Pattern
- Visitor Pattern
- Factory Pattern
- Factory Method Pattern
- Decorator Pattern
- Composite Pattern
Linked from
- The filesystem is the architecture
- The structural domain
- Runtime Discovery / Dynamic Binding
- Core Modular Design
- SOLID / Object-Oriented Design
- Behavioral Patterns
- Creational Patterns
- Structural Patterns
- Plugin / Extensibility / IoC
- Quality Attributes
- SOLID / Object-Oriented Design
- Architectural Clusters
- Severity levels
- The resolutions