This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I was reading the chapter 3 from Head First Design Patterns, about the Decorator Pattern.
In the class diagram, they created an abstract class to be the base of each decorator. But they didn't put the reference to the object being wrapped inside this abstract class. This reference was created on each new decorator, instead.
I am confused about this.
In the Wikipedia class diagram, this is different, with the reference to the wrapped object inside the decorator abstract class, which appears to be the best solution for me.
Is there any reason for the Head First author to put it that way?
If that 'component' arrow in the Head First book (either as UML standard or the book's standard) means 'composition', then maybe you can write the author about it. It could have been left out because the arrow already implies that relationship.
Also, the head first version, sort of adds a layer to identify that those components are CondimentDecorators, without adding anything, except the required getDescription().
I would say, that in the end, both the wiki and head first are okay; it is up to your choice where to put the decorated object.