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.4 Relationships between attribute values

We have formulated an invariant reflecting the fact that the sex of a patient must be the same as the type of ward to which they are admitted (see the discussion following Activity 14). We also know that each ward has a maximum capacity. The number of free beds must be consistent with this, leading to the following invariant:

For each object, the value of its attribute is less than or equal to the value of its attribute.

Activity 20

The invariant we have just discussed constrains the relative values of two attributes of the same object. Write down a real-world constraint that requires a similar invariant involving attributes of another class in the Hospital System.

Discussion

A patient's age is the difference (in years) between the current date and their date of birth.

The invariant noted in Activity 20 could be formulated as follows:

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.

M256_1

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