© Vaskaran Sarcar 2018
V. SarcarDesign Patterns in C#https://doi.org/10.1007/978-1-4842-3640-6_7

7. Decorator Pattern

Vaskaran Sarcar1  
(1)
Whitefield, Bangalore, Karnataka, India
 

This chapter covers the Decorator pattern.

GoF Definition

Attach additional responsibilities to an object dynamically. Decorators provide a flexible alternative to subclassing for extending functionality.

Concept

This pattern promotes the concept that your class should be closed for modification but open for extension. In other words, you can add a functionality without disturbing the existing functionalities. The concept is useful when you want to add some special functionality to a specific object instead of the whole class. This pattern prefers object composition over inheritance. ...

Get Design Patterns in C#: A Hands-on Guide with Real-World Examples now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.