Code on a screen, representing the open-closed principle.

Open to extension, closed to modification.

What the open-closed principle is

The open-closed principle is a software design guideline stating that software entities should be open for extension but closed for modification. This means it should be possible to add new behavior to a component without changing its existing code. The principle is one of the five SOLID principles of object-oriented design, aimed at making software easier to extend safely. The name captures the two qualities it asks of a component at once: openness to new behavior and closure against edits to what already works.

Open for extension

Being open for extension means that the behavior of a component can be extended to do new things. As requirements grow, you should be able to add new capabilities. The principle values designs that make this possible, so that the software can evolve to meet new needs. Extension is about adding to what a component can do.

Closed for modification

Being closed for modification means that adding new behavior should not require changing the existing, working code of a component. The existing code stays as it is, while new behavior is added around or alongside it. This is valuable because modifying tested code risks introducing bugs, so avoiding changes to it helps keep the software stable as it grows.

Why it helps

The open-closed principle helps because it lets software grow without disturbing what already works. By adding new behavior through extension rather than by editing existing code, the risk of breaking tested functionality is reduced. This makes the system safer to evolve over time. Being able to extend without modifying is a key to maintainable, adaptable software.

The principle in context

The open-closed principle is part of the SOLID set and relies on designs that allow extension, often through abstractions. It fits with other principles that aim for flexible, maintainable code. Understanding the open-closed principle clarifies an important goal in design: enabling new behavior to be added without changing existing code.

Why it matters

The open-closed principle is an important guideline in software design. Understanding what it is - open for extension but closed for modification - clarifies how to add new behavior safely without disturbing existing code. For anyone learning software design, it is a valuable concept to understand.

See also: What are SOLID principles? Explained, What is abstraction in programming? Explained.

Sources

Published date reflects the original event date (2026-10-20). This article is original Skillo editorial written from the sources above; facts were verified in September 2026.

Skillo Staff

Skillo Staff

All stories by: Skillo Staff

Leave a Reply