26.4. When to Define a Conceptual Subclass
Rules to ensure that a subclass is correct have been examined (the Is-a and 100% rules). However, when should we even bother to define a subclass? First, a definition: A conceptual class partition is a division of a conceptual class into disjoint subclasses (or types in Odell's terminology) [MO95].
The question may be restated as:
“When is it useful to show a conceptual class partition? |
For example, in the POS domain, Customer may be correctly partitioned (or subclassed) into MaleCustomer and FemaleCustomer. But, is it relevant or useful to show this in our model (see Figure 26.6)?
This partition is not useful for our domain; the next section explains why.
Motivations to Partition a Conceptual Class into Subclasses
The following are strong motivations to partition a class into subclass:
Create a conceptual subclass of a superclass when:
The subclass has additional attributes of interest. The subclass has additional associations of interest. The subclass concept is operated on, handled, reacted to, or manipulated differently than the superclass or other subclasses, in ways that are of interest. The subclass concept represents an animate thing (for example, animal, robot) that behaves differently than the superclass or other subclasses, in ways that are of interest.
|
Based on the above criteria, it is not compelling to partition Customer into the subclasses MaleCustomer and FemaleCustomer because they have no additional attributes or associations, are not operated on (treated) differently, and do not behave differently in ways that are of interest.
Table 26.2 shows some examples of class partitions from the domain of payments and other areas, using these criteria.
Table 26.2. Example subclass partitions.Conceptual Subclass Motivation | Examples |
---|
The subclass has additional attributes of interest. | Payments—
not applicable.
Library—
Book, subclass of LoanableResource, has an ISBN attribute. |
The subclass has additional associations of interest. | Payments—
CreditPayment, subclass of Payment, is associated with a CreditCard.
Library—
Video, subclass of LoanableResource, is associated with Director. |
The subclass concept is operated upon, handled, reacted to, or manipulated differently than the superclass or other subclasses, in ways that are of interest. | Payments—
CreditPayment, subclass of Payment, is handled differently than other kinds of payments in how it is authorized.
Library—
Software, subclass of LoanableResource, requires a deposit before it may be loaned. |
The subclass concept represents an animate thing (for example, animal, robot) that behaves differently than the superclass or other subclasses, in ways that are of interest. | Payments—
not applicable.
Library—
not applicable.
Market Research—
MaleHuman, subclass of Human, behaves differently than FemaleHuman with respect to shopping habits. |