Wednesday 28 June 2017

Software Engineering: Composite Pattern

Structural Pattern - Composite Pattern


Intent
Compose objects into tree structures to represent part-whole hierarchies. Composite lets clients treat individual objects and compositions of objects uniformly.

Why is this used?
This allows us to build structures of objects in the form of trees that contain both compositions of objects and individual object nodes.

Using a Composite structure, we can apply the same operations over both composites and individual objects. In other words, in most cases, we can ignore the difference between the composition of objects and individual objects.


UML diagram representation

https://www.codeproject.com/KB/Blogs/186192/1.jpg

Source code example

https://www.tutorialspoint.com/design_pattern/composite_pattern.htm

More to follow...

No comments:

Post a Comment

Software Engineering: Bad Smells! (Smelly code)

Bad Smells! What are bad smells? This refers to any symptom in the source code of a program that possibly indicates a deeper problem.  ...