Composites with Cycles

The nontree composite that Challenge 5.4 refers to was an accident. For physical objects, you may want to disallow the notion that an object is contained by more than one other object. Physical objects also usually cannot appear in cyclic models, in which an object ultimately contains itself. However, a problem domain can have nonphysical elements where cycles of containment make sense. This occurs frequently when modeling process flows.

Consider the construction of aerial shells such as the one that Figure 5.6 depicts. We launch a shell from a mortar by igniting the lifting charge of black powder that is seated beneath the core charge. The secondary fuses burn while the shell in the air, eventually reaching the core. When ...

Get Design Patterns Java™ Workbook 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.