The inheritance hierarchy
The concept of inheritance displays an effective method of sharing related code across numerous components.
Although we are free to use the option of the extends
attribute when writing our ColdFusion components to inherit and use methods from other components (in fact, we use the process in Chapter 7 to share a single common method amongst multiple components), in the world of object-oriented programming we need to follow a few specific guidelines to ensure we are implementing inheritance and not merely sharing code.
Specialization
An easy way to understand specialization is to visualize the children and parent objects as a ladder, where each rung is a level of objects.
In our e-commerce application, we could use the following diagram:
In the previous image, we have three tiers of objects. At the top is the parent object or super-component. If were to move from the top tier travelling down our object hierarchy, each level we reach contains an object that is a more...