Chapter 3. Structural Patterns – Composite and Flyweight
We have already seen three structural patterns: the decorator, proxy, and bridge patterns that provide us with ways of adding state and behavior dynamically, controlling the creation and access of objects, and keeping specifications and implementations separate. This chapter will now focus on the composite and flyweight patterns that are designed to facilitate the manipulation of a group of objects or large number of small objects. The composite is often used and we can also make use of the flyweight pattern.
The flyweight pattern efficiently shares the common information present in small objects by helping you reduce the memory consumption or storage requirements when many values are duplicated.
In this chapter, we will discuss the following topics:
- The composite pattern
- The flyweight pattern
The objectives of these two new structural patterns are described in the following table:
Pattern |
Objective |
---|---|
The composite pattern... |