Chapter 2: Preparing for the project work
23
or more related classes of things and allow the production of a number
of contrasting reports. You should not attempt designs that exceed five
classes. Two classes is probably too simple but
may be the starting point
for your work.
Consider this example. Develop a database that will allow a person to
review all the films that are on in London this week and discover at
which cinemas they are showing. The aim is to help people plan their
entertainment and book tickets.
At first sight this suggests two classes of
things about which a system
will store data – various films and various cinemas – and of course the
association between them (an association is the name we use for the link
between things of one class and things of another. This usage comes from
UML. Sometimes we express the same idea as a ‘relationship’).
2001: A
Space Odyssey – a classic film from 1968 by
Stanley Kubrick and in part
about computers – is showing at five particular cinemas. A user of the
database would want to know this to answer their query about
where the
film is showing. But, just knowing where is not enough. They will want
to know
when. This will lead us to add another class –
another class of
relevant thing in the world – which we might call a showing or screening.
We will then need to reflect in our class diagram these three classes. Below
are two simple examples of such class diagrams with the second one
showing some of the attributes (data items) that we would want to store
for items of each of the three classes.
Dostları ilə paylaş: