Composition allows classes to be open for extension but closed for modification.
By using composition, you can extend the behavior of a class by adding new components rather than changing existing code. This adheres to the open/closed principle, which states that software entities should be open for extension but closed for modification. For example, a 'NotificationService' class can add new notification types (e.g., SMS, Email) without modifying its core logic.
Additional Notes
How does composition support the open/closed principle?