31. Composite
© Jennifer M. Kohnke
A composite is a euphemism for a lie. It’s disorderly. It’s dishonest and it’s not journalism.
—Fred W. Friendly, 1984
The COMPOSITE pattern is a very simple pattern that has significant implications. The fundamental structure of the COMPOSITE pattern is shown in Figure 31-1. Here, we see a hierarchy based on shapes. The Shape
base class has two derivative shapes: Circle
and Square
. The third derivative is the composite. CompositeShape
keeps a list of many Shape
instances. When called on CompositeShape
, Draw()
delegates that method to all the Shape
instances in the list.
Thus, ...
Get Agile Principles, Patterns, and Practices in C# 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.