In Decorator pattern you are supposed to wrap decorators around one central ConcreteComponent. But as far as I can see from looking at the class diagram (from Wikipedia) is that nothing is stopping me from using a ConcreteDecorator as the central element. And this is obviously not great, because its implementation of operation() most probably contains component.operation(). Do I miss something here? Is there a guard that I do not see that makes sure that the central element that is being decorated is a ConcreteComponent?

Aucun commentaire:
Enregistrer un commentaire