Information générale
Catégorie:
Programmation Orientée Object
Titre:
Decorator pattern question
All,
I want to use a Decorator pattern, but I have a question.
If you chain functionality by using multiple decorators, don't you need a generic way to access that functionality, especially in any decorator not at the "end" of the chain.
For example, I have an object, Object1 and two decorators, Decorator1 & Decorator2. Decorator1 has Function1 and Decorator2 has Function2.
I instantiate a combination object with:
loCombinedObject = CREATEOBJECT("Decorator1",CREATEOBJECT("Decorator2,CREATEOBJECT("Object1")))
I now want to access This.Function2, but it does not exist. Function2 is accessed by This.oRef.Function2. What if I have more than just 2 decorators, I would have to know in what order the decorators were instantiated in order to access the decorator properties. I would need some sort of a generic routine to search the instantiation tree looking for the property/method.
Am I making any sense, or have I overlooked something?
TIA
Rex
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement