Skip to content

Glossary: Software Design Patterns in Go

Open/closed principle (OCP)

Also written: OCP, open/closed, open for extension, closed for modification

The SOLID principle that code should be open for extension but closed for modification. You add behavior with new code, such as a new discount type, instead of editing code that already works.

Where the book teaches it

Related terms

SOLIDPlugin