Desktop version

Home arrow Computer Science arrow Object-Oriented Analysis and Design for Information Systems Modeling with UML, OCL, and IFML

Source

Temporal patterns

Frequently the analyst faces the need to deal with time. For example, it may be necessary to represent the relations between people and their jobs. But, if the association between people and jobs

FIGURE 7.23

State of the accounts after the delivery of 25 books.

FIGURE 7.24

Evolution of Account/Transaction with memo entries.

FIGURE 7.25_

A generic primitive type Range.

FIGURE 7.26

Use of the effectivity pattern.

represents only the present time, then the information of former jobs will be lost when someone quits the job. This section discusses some patterns that deal with that important notion."

Effectivity

When an object is valid for some time (for example, a temperature measure, which has a time it was taken and a time it is considered valid), then the effectivity pattern may be used. It consists of declaring an effective attribute in the class, which is typed with a range, as seen in Figure 7.26.

History

If historical information has to be stored about the past states of an association, then the history association pattern may be used. This kind of association may be identified by the stereotype «history», as seen in Figure 7.27.

The stereotype of the association of Figure 7.27 means that a person must have just zero or one job currently, but she may have had other jobs in the past. These past jobs may be recovered as items in a list. In other words, it is possible to recover the last job, the job before the last, and so on.

When it comes to design, each class with an association with a navigable role implements a method for accessing the elements linked. In the example of Figure 7.27, the design class for Person would have a getter method getJobQ that returns the company of the current job of a person or the empty set if there is no current job. If the association is stereotyped with «history», in addition to that standard method there would exist another method with a parameter, getJob{index:Natural), [1]

FIGURE 7.27

An example of the history association pattern.

FIGURE 7.28

Concrete model for the <<history>> stereotype.

where getJob(Y) returns the current job, getJob(2) returns the last job, getJob(3) returns the job before the last, and so on. If there is no job for the index given, then the method returns the empty set.

In practice, this pattern can be modeled by two associations, as shown in Figure 7.28. The stereotype is, then, a way to abbreviate that complex structure, replacing it with a simpler one.

  • [1] Martin Fowler presents a nice summary on many temporal patterns at http://martinfowler.com/eaaDev/timeNarrative.html.
 
Source
Found a mistake? Please highlight the word and press Shift + Enter  
< Prev   CONTENTS   Next >

Related topics