Open-Closed Principle

Noun · Development

Definitions

  1. The 'O' in SOLID: software entities (classes, modules, functions) should be open for extension but closed for modification — meaning you can add new behavior by writing new code (subclasses, plugins, strategy implementations) without altering existing, tested code.

    In plain English: Design your code so you can add new features by plugging in new pieces rather than rewriting what already works.

    Example: "Adding a new payment provider should be a new class that implements the PaymentGateway interface, not an edit to a giant switch statement — that's the open-closed principle."

Related Terms