Faculty of Science and Engineering

Mock Exam blah blah

n:00 to (n+1):30

Instructions to Candidates: Answer any TWO questions.

All questions carry equal weight.

1. The following is part of the specification of a university library system:

The library contains books and journals. It may have several copies of a given book. Some of the books are for short term loans only. All other books may be borrowed by any library member for three weeks. Only members of staff may borrow journals. It’s essential that the system keep track of when books are borrowed and returned, since the current system already does that. The new system should produce reminders when a book is overdue. Preferably, the system should allow users (including staff-members) to check whether a book is on loan and reserve a copy of the book. There may in future be a requirement for users to be able to extend the loan of a book if it is not reserved.

a) The following list of candidate classes has been identified by simplemindedly applying the noun identification technique:

• library

• book

• journal

• copy

• short term loan

• library member

• week

• member of staff

• system

• current system

• reminder

• user

• staff-member

• loan

• requirement

Consider each noun phrase in turn, and decide whether it is indeed an appropriate class. For each candidate that you discard, explain why in at most one sentence. [5 marks]

b) Develop a conceptual class model relating the classes you retained in (a). You need not consider attributes and operations. [10 marks]

c) Develop a use case model for the system. [5 marks]

d) Comment on any remaining issues: are there any respects in which the specification is ambiguous or likely to be wrong? [5 marks] (i) Name the two kinds of UML implementation diagrams covered in the course, and describe in a few words what each expresses. For one kind of implementation diagram, draw a simple example diagram. [5 marks]

(ii) (a) In software engineering, what are design patterns, and what are they for? [5 marks]

Mediator is a design pattern. The idea is to define an object (the mediator or director) that encapsulates how a set of objects interacts. Instead of referring to each other explicitly, the objects interact via the director.

For example, consider the following simple kind of dialog box in which the user must select one item from a list box, and after that can do some action on the selection by pressing the Do It button. Until the user makes a selection, the “Selection:” text field is empty and the “Do It” button is disabled. When the user selects an item from the list box, the dialog’s director must copy that item to the “Selection:” text field and enable the “Do It” button.

The class diagram is as follows:

Notice that the class DialogDirector provides the basic facilities which must be provided by the director of any dialog box; the subclass SimpleDialogDirector redefines the method widgetChanged which it inherits from DialogDirector, in order to define the particular behaviour required of the simple dialog shown in the diagram above. (For simplicity, this class model does not show any attributes of the classes, and omits some operations which are not relevant here.)

b) After studying the class diagram, draw a sequence diagram to describe the following interaction:

A client program (show this as an actor) tells the director to display the dialog. The user clicks on an entry in the list box. The list box tells its director that it’s changed. The director passes the selection to the entry field. Now that the entry field contains some text, the director enables the button for initiating the action. [10 marks]

c) What advantages and disadvantages can you see of using this pattern, rather than letting the objects communicate directly with one another? [5 marks] 3. [Insert Q3 from the 97 exam paper here: it could still be set under the new syllabus]

Remarks on this mock paper

It will be in the normal 2 out of 3 questions format, but I make no guarantees about whether particular questions will cover particular parts of the course.

As I said before, this paper hasn’t been through the usual checking process. I think it would get through, probably, though question 2 is perhaps a bit regurgitation-based: I might be asked to make it involve more problem-solving. I’d probably also have to be more careful about the wording to make sure that the situation with the dialog boxes is clear.

I’m not going to produce sample answers, but if this brings any confusion to light do ask about it.

The example in Question 1 is from Rob Pooley’s and my draft book; the example in Question 2 is adapted from the Mediator pattern in Gamma et al.s design patterns book. Unfortunately for a real exam I have to make things up from scratch (or use extremely obscure sources)!