Java Reference
In-Depth Information
The verb/noun method
This method is all about identifying classes and objects, and the associations and interac-
tions between them. The nouns in a human language describe “things,” such as people,
buildings, and so on. The verbs describe “actions,” such as writing, eating, etc. From these
natural-language concepts, we can see that, in a description of a programming problem, the
nouns will often correspond to classes and objects, whereas the verbs will correspond to the
things those objects do—that is, to methods. We do not need a very long description to be
able to illustrate this technique. The description typically needs to be only a few paragraphs
in length.
verb/noun Classes
in a system roughly
correspond to
nouns in the
system's description.
Methods correspond
to verbs.
The example we will use to discuss this process is the design of a cinema booking system.
The cinema booking example
This time, we will not start by extending an existing project. We now assume that we are
in a situation where it is our task to create a new application from scratch. The task is to
create a system that can be used by a company operating cinemas to handle bookings of
seats for movie screenings. People often call in advance to reserve seats. The application
should, then, be able to find empty seats for a requested screening and reserve them for the
We will assume that we have had several meetings with the cinema operators, during which
they have described to us the functionality they expect from the system. (Understanding what
the expected functionality is, describing it, and agreeing about it with a client is a significant
problem in itself. This, however, is outside the scope of this topic and can be studied in other
courses and other topics.)
Here is the description we wrote for our cinema booking system:
The cinema booking system should store seat bookings for multiple theaters.
Each theater has seats arranged in rows. Customers can reserve seats and are given
a row number and a seat number. They may request bookings of several adjoining seats.
Each booking is for a particular show (that is, the screening of a given movie
at a certain time). Shows are at an assigned date and time and are scheduled for
a theater where they are screened. The system stores the customer's telephone
Given a reasonably clear description such as this, we can make a first attempt at discovering
classes and methods by identifying the nouns and verbs in the text.
Discovering classes
The first step in identifying the classes is to go through the description and mark all the
nouns and verbs in the text. Doing this, we find the following nouns and verbs. (The nouns are
shown in the order in which they appear in the text; verbs are shown attached to the nouns they
refer to.)
Search WWH ::

Custom Search