skip to Main Content

Welcome

Say hello to the toggle bar. This is an optional section you can use to display any content you'd like. Simply select a page from the theme panel and the content of the page will display here. You can even use the drag and drop builder to create this! This is a perfect place for your company mission statement, alerts, notices or anything else.

Get In Touch

Email: support@total.com
Phone: 1-800-Total-Theme
Address: Las Vegas, Nevada

Our Location

togglebar-map

Decorator Pattern

Post Series: Structual Design Pattern

This pattern add new functionality to an existing object without changing its structure. It creates a decorator class which wraps the original class and add new behaviors/operations to an object at run-time.

 

Component: This is an interface containing members that will be implemented by ConcreteClass and Decorator.
ConcreteComponent: This is a class which implements the Component interface.
Decorator: This is an abstract class which implements the Component interface and contains the reference to a Component instance. This class also acts as base class for all decorators for components.
ConcreteDecorator: This is a class which inherits from Decorator class and provides a decorator for components.

Implement

  1. Wrap old component by a decorator class
  2. Write new operator
  3. Using Factory pattern to choose which class can be use

Usage

  1. Add additional state or behavior to an object dynamically.
  2. Make changes to some objects in a class without affecting others.
  3. Resolve inherit from multi class

Resource

http://www.dotnettricks.com/learn/designpatterns/decorator-design-pattern-dotnet

https://www.codeproject.com/Articles/578816/Building-an-application-using-design-patterns-and

Leave a Reply

Your email address will not be published. Required fields are marked *

Back To Top