Definition

“A module should be open for extensions, but closed for modifications.”

This principle ensures extension of modules/components without changing the core source code of the application.

Tool Used: Polymorphism Protocols

Note: Open-Closed Principle can be enforced without the implementation of Protocols. But the use of Protocol is considered best practice.

Example

center center

center