Chapter    15

The Composite Pattern

The composite pattern is not as broadly applicable as some of the other design patterns I describe in this book, but it remains an important pattern because of the way it applies consistency to a data structure that contains different types of object. Table 15-1 puts the composite pattern in context.

Table 15-1. Putting the Composite Pattern into Context

Question

Answer

What is it?

The composite pattern allows a tree of individual objects and collections of objects to be treated consistently.

What are the benefits?

The consistency that the composite pattern brings means that components that operate on the tree structure are simpler and do not need to have knowledge of the different objects types that are in use. ...

Get Pro Design Patterns in Swift now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.