Skip to content

Open/Closed Principle

Software entities should be open for extension but closed for modification, because modifying working code risks breaking existing behavior while extension preserves stability.

Tension Addressed

YAGNI vs. Extensibility

Recognizable As

Plugin architectures, strategy injection, template methods, polymorphic dispatch points, hook methods, middleware pipelines

Canonical Sources

Meyer, "Object-Oriented Software Construction" (1988); Martin, "Agile Software Development" (2002)

Transfers To

Software Architecture (extensible systems), API Design (versioning without breaking changes), Testing (test doubles via interfaces)

The principle's power comes from identifying stable abstractions. Extension points at volatile boundaries provide value; extension points everywhere create unnecessary complexity.