Decorator: This is an abstract class which acts as the base class for the ConcreteDecorator This abstract class implements Component interface and keeps reference to Component class instance.ConcreteComponent: It defines an object to which additional responsibilities can be added dynamically.It is implemented by ConcreteComponent class and Decorator abstract class. Component: This is an interface for actual/existing objects which functionality will be modified dynamically.Decorators provide a flexible alternative to subclassing for extending functionality. This wrapper class is responsible for adding additional functionalities to the existing class.Īttach additional responsibilities to an object dynamically. This design pattern provides a decorator class which acts as the wrapper of the existing class. The decorator design pattern is used where there is need to add additional functionality to already existing object without altering its structure. As the name suggests it is used to decorate (modify/change) an existing object without changing its original behavior. This article explains what is decorator pattern and how to implement decorator design pattern in C#.ĭecorator design pattern comes under structural design pattern category of Gang of four (GoF) design patterns.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |