Examples of Decorator design pattern implemented in Java and Python [2]. The Java example uses the concept of pizza and pizza toppings to exemplify this pattern [3].
In object-oriented programming, decorator pattern is a flexible alternative to subclassing for extending funcionality. It allows to attach additional responsabilities to an object dynamically, without affecting the behaviour of other objects from the same class. It is often useful for adhering to the Single Responsibility Principle, as it allows functionality to be divided between classes with unique areas of concern. Decorator use can be more efficient than subclassing, because an object's behavior can be augmented without defining an entirely new object [1].
Fig. 1 - UML class design of Decorator pattern.
J. Rico, (2019) Decorator pattern examples in Java and Python.
[Source code](https://github.com/jvirico/pizza_decorator)
[1] - Decorator Pattern Wikipedia
[2] - SHVETS, Alexander. Dive Into Design Patterns. Refactoring. Guru, 2018.
[3] - PPCU, Budapest. Design Patterns