|
Posted by Willem Bogaerts on 09/28/07 08:03
> I'm trying to learn patterns, which I hope to use in my PHP code,
> although I'm finding it hard to get any real impression of how patterns
> fit in properly, I've done the following test code for Decorator pattern
> and want to know:
>
> a) is it correct, this is decorator pattern?
> b) how would i use this in practice with a database, eg. how would i
> store the 'attributes' in tables, and how would the 'pattern' be used in
> conjunction?
>
> Any hints, tips, pointers to examples would be appreciated:
The GOF book ("Design Patterns") is quite clear, I think.
<snipped example>
A decorator is a class that adds functionality at runtime. Functionality
you could add to your objects in that way are things like spread
payment, discount conditions, etc. The point of the pattern is that you
can add responsibility to specific objects instead of whole classes. It
is an alternative to subclassing (your example was subclassing).
Best regards,
--
Willem Bogaerts
Application smith
Kratz B.V.
http://www.kratz.nl/
[Back to original message]
|