CSE2305 - Object-Oriented Software Engineering
exercises

CSE2305
Object-Oriented Software Engineering

Exercise 1: Vic Roads Database: solution

 

You were asked to perform a basic object-oriented analysis for developing a database for VicRoads, based on information provided on their web site.

There are three principle classes to deal with:

Observations:
A person may own many vehicles of the same or different types.
A person requires a licence to drive a vehicle on public roads.
Different vehicle types require different licences.
Some licence types allow you to drive more than one class of vehicle.
A person may have more than one type of license.
Some vehicles are defined as the combination of other vehicles.

We can encapsulate this information in three major classes (Vehicle, Person, and Licence).

Vehicle and Licence are abstract base classes – they'll need further specialization. The diagram shows one person may have many licences and many vehicles; a vehicle has registration and that registration belongs to a person (we ignore the possibility that companies may register vehicles).

Next, let's look at Vehicle in more detail. A key point is that a "vehicle" may include various components, for example a car may have a trailer. This is an example of the compositional design pattern (see Topic 18 and the Design Patterns book).

All this information is taken from the Vic Roads web site. We could add a couple more types (e.g. sidecar), but in the analysis phase this gives a reasonable overview.

Next driver's licences: drivers may have more than one licence, but a licence belongs only to one person. Different licences are required for different vehicle types.

Note that these diagrams say nothing about the rules for owning licences or vehicles (e.g. what type of vehicle can be driven with what licence). How do you think you could express this functionality?


This material is part of the CSE2305 – Object-Oriented Software Engineering course.
Copyright © Jon McCormack, 2005.  All rights reserved.

Last modified: August 10, 2005