The Composite Pattern
Learn about the Adapter pattern and its implementation using a coding example.
We'll cover the following
Overview
The Composite pattern allows complex tree structures to be built from simple components, often called nodes. A node with children will behave like a container; a node without children will behave like a single object. A composite object is—generally—a container object, where the content may be another composite object.
Traditionally, each node in a composite object must be either a leaf node (that cannot contain other objects) or a composite node. The key is that both composite and leaf nodes can have the same interface. The following UML diagram shows this elegant parallelism as a some_action()
method:
Get hands-on with 1400+ tech skills courses.