View Single Post

  #4 (permalink)  
Old 12-30-2005, 05:59 PM
iscy
Guest
 
Posts: n/a
Re: Design Patterns - Maze Examples

> For Decorator, think of a file you have to send to possibly many places
> via many methods. The basis method is to move file from place A to file
> path B. You may also need to email it to someone: make an EmailDecorator.
> If you need to FTP it anywhere, add an FtpDecorator.
> And so on.


This example is closer to a strategy than to a decorator. Don't forget
something. The decorator is a strutural pattern, not a behavioral
pattern as your example describes.

In other words, the decorator allows you to add responsabilities to an
object dynamically. There is a base class that your object will know
that will be called the 'decorator' itself. That will let you inherit
this base class to create child classes having different
responsabilities. The main difference with the strategy, is that you
can attach more than one decorator to an object. That means, you are
using multiple decorators at the same time. In other words, your
dispatching the responsabilites of something through several objects.
The is the job of the object that is using the base class to iterator
through all of them and notify them.

Reply With Quote