June 2016
Intermediate to advanced
290 pages
6h 45m
English
In the previous chapter I mentioned that we would like to avoid coupling our objects together tightly. Inheritance is a very strong form of coupling and I suggested that, instead, composites should be used. The composite pattern is a special case of this in which the composite is treated as interchangeable with the components. Let's explore how the composite pattern works.
The following class diagram contains two different ways to build a composite component:

In the first one, the composite component is built from a fixed number of a variety of components. The second component is constructed from a collection of indeterminate length. In ...
Read now
Unlock full access