How do design patterns help in adhering to OCP?
Several design patterns are built around the idea of making systems extensible without
modifying core logic:
Pattern How It Helps With OCP
Strategy Allows changing behavior by swapping strategies.
Decorator Adds new responsibilities dynamically without changing original code.
Template Method Allows subclasses to override certain steps in an algorithm.
Factory Method Makes it easy to introduce new types without altering existing logic.
Observer Extends behavior in reaction to events without altering the source.