O Open Closed Principle OCP · TL;DR

1 min read
Mid-level3 min read
Rapid overview

TL;DR

OCP says you should be able to add new behaviour by writing new code, not by editing the code that already works. In practice that means programming against interfaces (payment processors, strategy objects, plugin registries) so a new variant ships without touching — or reviewing, or re-testing — every existing call site.

See also