6.2.2 Constraints on the values of particular attributes
The requirements document states:
The system displays … for each such junior doctor, their grade (1, 2 or 3).
This constraint could be included in the model as the following invariant:
The attribute of each object has a value which is either 1, 2 or 3.
Similarly, there are constraints on the sex of patients and the type of ward (which must be male or female in both cases). We take the view that invariants involving the uniqueness of attribute values or the allowable values of a single attribute are most simply and clearly expressed in a comment alongside that attribute in the class description, as we have done in the case of the descriptions for the Hospital System.
In addition to constraints arising from the requirements document, there can be restrictions on attribute values that are just ‘common sense’ -such as the date of birth of a patient not being later than the current date, or the number of free beds on a ward being non-negative. It is not necessary at this stage to identify such constraints explicitly.