Tag Archives: decorator-pattern

Design Patterns: Decorator

The decorator design pattern comes in handy when we need to add behavior or state to an object during run-time. It allows you to change the behavior of a class at run-time without having to change the core code.

It can be used, for example, to add logging capabilities to an instance. It works by wrapping the original class in the decorator class, invoking the methods where applicable and invoking the custom behavior at the same time.
Continue reading