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.3 Numbers of links between objects

There are a number of invariants shown by the multiplicities of the associations in the class diagram. These do not need to be listed. However not all conditions on the number of links between objects are evident from the class diagram. As we have discussed, the relationship between teams and the doctors that comprise them has been modelled as a single association between and rather than as two separate associations, one between and , and one between and . Although the multiplicity at the end of correctly reflects the number of doctors that can be contained in a team, it does not fully reflect the allowable number of junior doctors and consultant doctors in a team.

Activity 19

Using the first part of the answer to Activity 15 as a model, write down two invariants, one which imposes a condition on the number of objects that may be linked via to a object, and one which imposes a condition on the number of objects that may be linked to a object.

Discussion

Discusssion

  1. Each object is linked via to exactly one object.

  2. Each object is linked to at least one object.

In the first invariant given in the discussion to Activity 19, notice the inclusion of ‘via ’ to identify the relevant association connecting and . This is because there are two associations between and (namely, and ), and it is therefore necessary to be explicit about the particular association being constrained. In other words, if in stating an invariant there is more than one association between two classes involved, it is necessary to specify an association name to clarify which association is being discussed.

The statement from the requirements document which gives rise to the two invariants in Activity 19 is as follows:

Each team is headed by a consultant doctor who is the only consultant doctor in the team; the rest of the team are all junior doctors, at least one of whom must be at grade 1.

It indicates that for both the answers to Activity 19 there is a need for an even tighter condition. The single consultant doctor in the team must be the consultant doctor that heads the team, and at least one of the junior doctors in the team must be at grade 1. The second invariant can be extended to reflect this, as follows:

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

We will return to the first invariant in Activity 21.

M256_1

Take your learning further371

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

If you are new to university level study, we offer two introductory routes to our qualifications. Find out Where to take your learning next?373 You could either choose to start with an Access courses374or an open box module, which allows you to count your previous learning towards an Open University qualification.

Not ready for University study then browse over 1000 free courses on OpenLearn375 and sign up to our newsletter376 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