Welcome to the Monastery | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
I don't have the gang of four here at my cubicle, but I do develop code which uses decorators. Decorator B should not "inherit" anything from A; they are more of a 'friend' relationship. In Perl, you would probably end up munging the symbol table to accomplish it. Decorators are added after-the-fact, per-instance, upon demand. So SOME instances of A also have B-like qualities, and SOME instances of A do not. Another way of saying it: You don't really say "make a new instance of a B," but instead, "make a new instance of an A, and then attach some B-ness to it."
This approach would still hold true, even if you make another Decorator like C. Some A instances may have B, some have C, some have both B and C, and some have neither. Update: You can then make a D class which inherits from A, but always attaches B-ness and C-ness. -- In reply to Re: Decorator(?) classes and inheritance
by halley
|
|