Decotator Pattern – Object Structural

Intent

Attach additional  responsibility to an object dynamically. Dcorators provide flexible alternative to subclassing for extending functionality.

Also Know As : Wrapper

Motivation

Sometimes we want to add responsibilites to individual objects, not to an entire class.

Applicability

Use Decorator:

  1. To add responsibilties to individual objects dynamically and transparently, that is without affecting other objects.
  2. For responsibilities that can be withdrawn.
  3. When extension by subclassing is impractical.

 

Structure

Decorator pattern
Decorator pattern structure

 

 

 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s