Java Reference
In-Depth Information
14.4.6 Reuse
Currently, our goal has been to simulate the operation of vehicles in order to assess the com-
mercial viability of expanding a business into a new area of the city. You may have noticed that
substantial parts of the application may actually be useful once the expansion is in operation.
Assuming that we develop a clever scheduling algorithm for our simulation to decide which vehicle
should take which call or that we have worked out a good scheme for deciding where to send the ve-
hicles to wait while they are idle, we might decide to use the same algorithms when the company ac-
tually operates in the new area. The visual representation of each vehicle's location could also help.
In other words, there is potential to turn the simulation of the taxi company into a taxi manage-
ment system used to help the real company in its operations. The structure of the application
would change, of course: the program would not control and move the taxis, but rather record
their positions, which it might receive from GPS (global positioning system) receivers in each ve-
hicle. However, many of the classes developed for the simulation could be reused with little or no
change. This illustrates the power of reuse that we gain from good class structure and class design.
Another example
There are many other projects that you could undertake along similar lines to the taxi company
application. A popular alternative is the issue of how to schedule elevators in a large building.
Coordination between elevators becomes particularly significant here. In addition, within an
enclosed building, it may be possible to estimate numbers of people on each floor and hence to
anticipate demand. There are also time-related behaviors to take account of: morning arrivals,
evening departures, and local peaks of activity around lunchtimes.
Use the approach we have outlined in this chapter to implement a simulation of a building with
one or more elevators.
Taking things further
We can only take you so far by presenting our own project ideas and showing you how we
would develop them. You will find that you can go much further if you develop your own ideas
for projects and implement them in your own way. Pick a topic that interests you, and work
through the stages we have outlined: analyze the problem, work out some scenarios, sketch out
a design, plan some implementation stages, and then make a start.
Designing and implementing programs is an exciting and creative activity. Like any worthwhile
activity, it takes time and practice to become proficient at it. So do not become discouraged
if your early efforts seem to take forever or are full of errors. That is normal, and you will
gradually improve with experience. Do not be too ambitious to start with, and expect to have to
rework your ideas as you go; that is all part of the natural learning process.
Most of all: Have fun!
Search WWH ::

Custom Search