This is the continuing post in a series of post on Design patterns.
Presently we are going through the structural patterns. I will be
writing about the composite pattern today.
You can read about the other patterns from the following links
Composite pattern deals with providing a structure such that a single
object ( component ) or a group of objects ( composite ) can be treated
in the same way. This saves the caller of this composite from knowing
the objects individually. Lets see an example.
As you can see in the above example, “group” is a composite containing
components of “person” but it might as well contain another composite
which also contains components of “person”. You can use a composite
pattern when you have to treat all objects in a composite in the same
way or when the consumer is not bothered of all but the basic
differences between individual object and their composite.
In my next post I will be talking about the Flyweight pattern.
Comments