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

5.2 Summary of criteria

We will end this section by summarising the criteria to be considered when deciding whether an event is best represented by a class or an association.

  • Does the event have any properties whose values need to be recorded? For example, in the Hospital System, had there been a need to record the date of a patient's treatment or the medication that a treatment involved, we would have modelled treatment by a class associated with and .

  • Does the event involve more than two other significant entities? For example, were nurses part of our system domain, a treatment might sometimes involve a nurse as well as the patient and the doctor. In that case too, a class would be necessary, since three objects would need to be linked rather than just two.

  • Do different occurrences of the event involving the same entities need to be recorded? For example, if there were a need to record each treatment of a given patient by a particular doctor, a class would be appropriate, because an association only allows for one link between the same two objects.

  • Where none of these situations pertains – when an event involves instances of only two classes, has no significant properties of its own, and where it is not necessary to record multiple occurrences involving the same two entities – the event should normally be modelled as an association between the two classes.

Activity 13

Consider the following excerpt from a requirements document for an Election Campaign System. Identify all the events in the description that should be represented in the conceptual model, decide which of them should be modelled by a class and which by an association, and give reasons for your decisions. Sketch a class diagram, excluding multiplicities.

A system is required to model the organisation of an election campaign by a constituency political party. During the campaign, local activists carry out telephone canvassing and visit local community organisations from which the party hopes to gain support. The party records all the telephone calls and visits that have taken place. In the case of telephone calls the date of the call is recorded, together with a note of any issues mentioned by the constituent as likely to influence their voting behaviour. The party also organises a number of public meetings in different parts of the constituency. Each of these meetings is chaired by a member of the local committee, and involves at least two speakers, a local activist and a guest speaker selected from a panel drawn up by the national headquarters of the party.

You may assume that the following classes have already been identified as necessary: , , , and .

Discussion

The description mentions three relevant types of event – visits to local organisations, public meetings and telephone conversations.

  • The visits involve only two classes – and . There is no indication that specific information needs to be recorded about visits or that their number is significant, so it is appropriate to model them by a association between and .

  • Public meetings, on the other hand, involve instances of three other classes: , and . It is therefore appropriate to model this event as a class.

  • Telephone conversations between party activists and constituents involve only two classes, but we are told that certain details of the conversation – the date on which it took place and the issues raised by the constituent – are recorded. To model this, a class is needed, which will have two attributes, and .

A class diagram for the system (excluding multiplicities) is given in Figure 24.

Figure 24
Figure 24 Class diagram for the Election Campaign System (excluding multiplicities)
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