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

8.2.3 Invariants

  1. The attribute of any object has the same value as the type attribute of the linked object.

  2. 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.

  3. 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.

  4. Each object is linked to at least one object for which the grade attribute has a value of 1.

  5. The object linked to a Object via is linked to the same Object via .

  6. The object linked to any object via is linked via to the object to which that object is linked.

  7. 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.


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