32.8. Modeling Changing States
Assume that a payment can either be in an unauthorized or authorized state, and it is meaningful to show this in the domain model (it may not really be, but assume so for the discussion). As shown in Figure 32.13, one modeling approach is to define subclasses of Payment: UnauthorizedPayment and AuthorizedPayment . However, note that a payment does not stay in one of these states; it typically transitions from unauthorized to authorized. This leads to the following guideline:
Figure 32.13. Modeling changing states.
Guideline Do not model the states of a concept X as subclasses of X. Rather, either:
|