Problem Analysis  «Prev  Next»
Lesson 10 Basic object modeling: constraints
ObjectiveConstraints as they apply to basic object modeling.

Basic Object Modeling - Constraints

Any rules that cannot be expressed in the name or in the multiplicity may be added as a constraint. Place the rule description within curly brackets {} at the end of the association controlled by the rule.

Constraints Example

In the previous example, we chose "a point in time" as our time frame. For this example, let's change the time frame to include history.
Now ask "How many customers can hold the same seat over the life of the system?"
In this case, the answer would be "only one at the same time, but many over a period of time."
This multiplicity would be represented as
0..*: zero to many customers may hold the same seat over time.

Only one at the same time, but many over a period of time

However, the multiplicity alone will not tell you that only one person may hold the seat at the same time. This added rule requires the use of a constraint.

Two approaches are equally valid:
  1. Use a multiplicity of 0..* and
  2. { only one at a time.

Only one at a time

In the last diagram, multiplicity by outlining the following characteristics:
  1. Use a multiplicity of 0..1 to show one at a time and
  2. a constraint of {historical} to show that you keep history.

Historical Constraints: One at a time and a constraint of {historical} to show that you keep history


Object Modeling Constraints - Exercise

Click the Exercise link below to draw class diagrams based on excerpts from the course project problem statement.
Object Modeling Constraints - Exercise