[Zope3-dev] Chapter 1 Step 6 now available
Steve Alexander
steve@cat-box.net
Mon, 18 Feb 2002 22:53:18 +0000
Tres Seaver wrote:
>
> My problem with Decorator is that it is the name of a recognized
> GoF design pattern; the Decorator pattern is somewhat like
> adapter, in that the decorating object wraps the decorated,
> but distinct in that the "depended on" and "provided" interfaces
> are the same.
>
> Maybe I misread Steve's description, and the GoF pattern actually
> fits.
Can you explain why you think my use doesn't fit?
I think it fits.
Take for example
Decorator.decorate(contactinfo, postalinfo)
...where contactinfo is an object implementing IContactInfo and
postalinfo is an object implementing IPostalInfo.
Let's call the resultant object decoratedobject.
If you ask for the interfaces that decoratedobject implements, it will
return exactly the same as contactinfo would.
If you ask for any other attribute of decoratedobject, it will return
exactly the same as contactinfo would, except where you ask for a method
of IPostalInfo, where the method of postalinfo will be returned.
Thus, decoratedobject is just like contactinfo, but with methods of
IPostalInfo bolted on.
Sounds like the Decorator pattern from "Design Patterns: elements of
reusable object-oriented software" to me.
--
Steve Alexander