Modelling object-oriented software – an introduction
Modelling object-oriented software – an introduction

Start this free course now. Just create an account and sign in. Enrol and complete the course for a free statement of participation or digital badge if available.

Free course

Modelling object-oriented software – an introduction

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.


Take your learning further

Making the decision to study can be a big step, which is why you'll want a trusted University. The Open University has 50 years’ experience delivering flexible learning and 170,000 students are studying with us right now. Take a look at all Open University courses.

If you are new to University-level study, we offer two introductory routes to our qualifications. You could either choose to start with an Access module, or a module which allows you to count your previous learning towards an Open University qualification. Read our guide on Where to take your learning next for more information.

Not ready for formal University study? Then browse over 1000 free courses on OpenLearn and sign up to our newsletter to hear about new free courses as they are released.

Every year, thousands of students decide to study with The Open University. With over 120 qualifications, we’ve got the right course for you.

Request an Open University prospectus371