32.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 32.6)? This partition is not useful for our domain; the next section explains why.
Figure 32.6. Legal conceptual class partition, but is it useful in our domain?
Motivations to Partition a Conceptual Class into Subclasses
The following are strong motivations to partition a class into subclasses:
Guideline Create a conceptual subclass of a superclass when:
|
[4] Men and women do exhibit different shopping habits. However, these are not relevant to our current use case requirementsthe criterion that bounds our investigation.
Table 32.2 shows some examples of class partitions from the domain of payments and other areas, using these criteria.
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. |