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.

发表评论

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

WordPress.com 徽标

您正在使用您的 WordPress.com 账号评论。 登出 /  更改 )

Google photo

您正在使用您的 Google 账号评论。 登出 /  更改 )

Twitter picture

您正在使用您的 Twitter 账号评论。 登出 /  更改 )

Facebook photo

您正在使用您的 Facebook 账号评论。 登出 /  更改 )

Connecting to %s