/composite

Simple project demonstrating the composite design pattern

Primary LanguageJavaApache License 2.0Apache-2.0

COMPOSITE

Code

Simple project representing the composite design pattern. For this one i've created a code that represents a book and its chapters.

Resume

Composite is a structural design pattern that lets you compose objects into tree structures and then work with these structures as if they were individual objects.

image

Definition

The composite pattern describes a group of objects that are treated the same way as a single instance of the same type of object. The intent of a composite is to "compose" objects into tree structures to represent part-whole hierarchies. Implementing the composite pattern lets clients treat individual objects and compositions uniformly.

image

When to use

Composite should be used when clients ignore the difference between compositions of objects and individual objects.[1] If programmers find that they are using multiple objects in the same way, and often have nearly identical code to handle each of them, then composite is a good choice; it is less complex in this situation to treat primitives and composites as homogeneous.

Source: Wikipedia | Refactoring Guru