Consider Figure 8-4. It shows the relationship between
Commonality/variability analysis
The conceptual, specification, and implementation perspectives
An abstract class, its interface, and its derived classes
As you can see in Figure 8-4, commonality analysis relates to the conceptual view of the problem domain and variability analysis relates to the implementation, that is, to specific cases.
The specification perspective lies in the middle. Both commonality and variability are involved in this perspective. The specification describes how to communicate with a set of objects that are conceptually similar. Each of these objects represents a variation of the common concept. This specification becomes an abstract class or an interface at the implementation level.
In the new perspective of object-oriented design, I can now say the following:
This simplifies the design process of the classes into a two-step procedure:
When Defining … | You Must Ask Yourself… |
---|---|
An abstract class (commonality) | What interface is needed to handle all of the responsibilities of this class? |
Derived classes | Given this particular implementation (this variation), how can I implement it with the given specification? |
The relationship between the specification perspective and the conceptual perspective is this: It identifies the interface I need to use to handle all of the cases of this concept (that is, the commonality).
The relationship between the specification perspective and the implementation perspective is this: Given this specification, how can I implement this particular case (this variation)?