8.2.3 Invariants
-
The
attribute of any
object has the same value as the type attribute of the linked
object.
-
For each
object, the value of its
attribute is equal to the difference (in years) between the current date and the value of its
attribute.
-
For each
object, the value of its
attribute is equal to the value of its
attribute minus the number of
objects to which it is linked.
-
Each
object is linked to at least one
object for which the grade attribute has a value of 1.
-
The
object linked to a
Object via
is linked to the same
Object via
.
-
The
object linked to any
object via
is linked via
to the
object to which that
object is linked.
-
If
is any
object, then any
object linked to
is also linked to the
object which is linked to
.
In order to complete the optional exercise below, you will need to refer to the PDF document attached below.
Click on the link below to view hospital requirements.
Requirements [Tip: hold Ctrl and click a link to open it in a new tab. (Hide tip)]
Optional activity
Our analysis of the Hospital System has been conducted in a rather artificial manner. We attempted to identify all the classes before identifying their attributes and then the associations between them. Similarly, we did not consider invariants until we had formed the class diagram and class descriptions, and did not identify derived attributes and associations until we had found all the invariants. In practice, you would use your understanding of the system domain to carry out these activities in parallel as you worked through the requirements document.
Here is a worthwhile activity which you can do now, if you have time. Go back to the requirements document for the Hospital System and work through it a sentence or two at a time, building up the class diagram (classes, associations and multiplicities) and class descriptions as you go, and noting any possible invariants and derived associations when they arise. You may be surprised at how easy it is to get most of the model correct in a short time. The areas requiring most thought are usually invariants and derived associations.