This section is bit conceptual in nature and those of you who have not dabbled with GoF design patterns will find it a bit difficult. The best strategy could be to skip this section and focus on the running example. Once you have understood the running example, this particular section can be revisited.
Object-oriented programming is very good at modeling hierarchies. In fact, the hierarchy can be considered the canonical data model for the object-oriented processing of data. In the GoF pattern world, we model hierarchies using the Composite pattern. The Composite pattern is categorized as a structural pattern. Whenever there is a Composite pattern used, the Visitor pattern will also be part of the system. The Visitor pattern is good for processing composites to add behavior to the structure. The Visitor/Composite patterns come as...