Java Reference
In-Depth Information
10 Further abstraction techniques
Main concepts discussed in this chapter:
abstract classes
multiple inheritance
Java constructs discussed in this chapter:
abstract, implements, interface
In this chapter, we examine further inheritance-related techniques that can be used to enhance
class structures and improve maintainability and extendibility. These techniques introduce an
improved method of representation of abstractions in object-oriented programs.
The previous two chapters have discussed the most important aspects of inheritance in applica-
tion design, but several more advanced uses and problems have been ignored so far. We will
now complete the picture with a more advanced example.
The project we use for this chapter is a simulation. We use it to discuss inheritance again and
see that we run into some new problems. Abstract classes and interfaces are then introduced to
deal with these problems.
Computers are frequently used to simulate real systems. These include systems that model traf-
fic flows in a city, forecast weather, simulate the spread of infection, analyze the stock market,
do environmental simulations, and much more. In fact, many of the most powerful computers
in the world are used for running some sort of simulation.
When creating a computer simulation, we try to model the behavior of a subset of the real world
in a software model. Every simulation is necessarily a simplification of the real thing. Deciding
which details to leave out and which to include is often a challenging task. The more detailed
a simulation is, the more accurate it may be in forecasting the behavior of the real system. But
more detail increases the complexity of the model and the requirements for both more comput-
ing power and more programmer time. A well-known example is weather forecasting: climate
models in weather simulations have been improved by adding more and more detail over the
last few decades. As a result, weather forecasts have improved significantly in accuracy (but are
far from perfect, as we all have experienced at some time). Much of this improvement has been
made possible through advances in computer technology.
Search WWH ::

Custom Search