Design Patterns · Junior · Question 27 of 75
What does the Open/Closed Principle (OCP) mean?
- ✓Correct answer: Code is open for extension but closed for modification
- 2Code should be open to everyone, i.e. open source
- 3Public methods are open, private ones are closed
Explanation
New behavior is added without rewriting proven code: via a new strategy, a plugin, or a component through props/children. Example: a Button with an icon prop instead of editing the button for every new icon.