Java Reference
In-Depth Information
cinema booking system
stores (seat bookings)
stores (telephone number)
seat booking
has (seats)
reserves (seats)
is given (row number, seat number)
requests (seat booking)
row number
seat number
is scheduled (in theater)
telephone number
The nouns we identified here give us a first approximation for classes in our system. As a first
cut, we can use one class for each noun. This is not an exact method; we might find later that
we need a few additional classes or that some of our nouns are not needed. This, however, we
will test a bit later. It is important not to exclude any nouns straight away; we do not yet have
enough information to make an informed decision.
Almost always when we do this exercise with students, some students immediately leave out
some nouns. For example, a student leaves out the noun “ row ” from the previous description.
When questioned about this, students often say: “Well, that's just a number, so I just use an int.
That doesn't need a class.” It is really important at this stage not to do this. We really do not
have enough information at this point to decide whether row should be an int or a class. We
can make this decision only much later. For now, we just go through the paragraph mechani-
cally, picking out all nouns. We make no judgments yet about which are “good ones” and which
are not.
You might like to note that all of the nouns have been written in their singular form. It is typical
that the names of classes are singular rather than plural. For instance, we would always choose
to define a class as Cinema rather than Cinemas . This is because the multiplicity is achieved
by creating multiple instances of a class.
Exercise 13.1 Review projects from earlier chapters in this topic. Are there any cases of
a class name being a plural name? If so, are those situations justified for a particular reason?
Search WWH ::

Custom Search