Software Design Patterns: Decorator in a Nutshell

This is a six-minute description of the Decorator pattern – from theory to code.

Let us talk about structural design patterns. Patterns help us to connect classes and objects in order to form larger structures. Decorator is one pattern in the structural category. The Decorator pattern allows extending (decorating) the functionality of an object. It is an alternative to inheritance. Decorator provides new functionality in run-time to a specific instance, while inheritance adds functionality at compilation time and the change affects all instances of the new class.

. . .

[Click here to continue reading on medium]