composite pattern (complicated!) — keywords

tree —

apache tiles — a good eg of the tree concept

subtree — a subtree and a leaf are treated the same, as 2 “components” — a lifeless abstract jargon.

operations — an operation can be an instance method (polymorphism) of the component, or can be a method accepting an arg of the component’s type.

Now the most important keyword is …

transparency — clients can treat subtree or leaf uniformly. Simply put, they share a supertype (interface or superclass). Transparency is big in OO layer design. Transparency means separation of concern.

Once you wrap your mind around it, you may finally sigh a sigh of relief and realize Composite is a simple and practical device (like factory, template method, State)

See [[head first design patterns]] for a simple eg.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s