Design Pattern: Decorator Pattern

In Decorator design pattern, our target is to add some new functionality to an existing object. Say, there is an existing class that is responsible for printing a UI element (like a Button or Table). Later we need the ability to add a border or text color to that element. We can add new properties and functions to that existing class and introduce those properties. But that will violate the Open-Close principle of the SOLID principle.

Design Pattern: Decorator Pattern in Java

Decorator pattern is used to attach a new functionality to an existing object, without changing the existing class. This article demonstrates Decorator pattern implementations in Java.