Java Reference
In-Depth Information
9.1 Inheritance Basics
We'll begin our discussion of inheritance by exploring how the concept originated
and considering a nonprogramming example that will lead us toward programming
with inheritance in Java.
Large programs demand that we write versatile and clear code on a large scale. In
this textbook, we've examined several ways to express programs more concisely and
elegantly on a small scale. Features like static methods, parameterization, loops, and
classes help us organize our programs and extract common features that can be used
in many places. This general practice is called code reuse.
Code Reuse
The practice of writing program code once and using it in many contexts.
Did You Know?
The Software Crisis
Software has been getting more and more complicated since the advent of pro-
gramming. By the early 1970s, teams writing larger and more complex programs
began to encounter some common problems. Despite much effort, software proj-
ects were running over budget and were not being completed on time; also, the
software often had bugs, didn't do what it was supposed to do, or was otherwise
of low quality. In his 1975 book The Mythical Man-Month: Essays on Software
Engineering , software engineer Fred Brooks argued that adding manpower to a
late software project often made it finish even later. Collectively, these problems
came to be called the “software crisis.”
A particularly sticky issue involved program maintenance. Companies found
that they spent much of their time not writing new code but modifying and main-
taining existing code (also called legacy code ). This proved to be a difficult task,
because it was easy to write disorganized and redundant code. Maintenance of such
code was likely to take a long time and to introduce new bugs into the system.
The negative effects of the software crisis and maintenance programming
were particularly noticeable when graphical user interfaces became prominent in
the 1980s. User interfaces in graphical systems like Microsoft Windows and
Apple's Mac OS X were much more sophisticated than the text interfaces that
preceded them. The original graphical programs were prone to redundancy
because they had to describe in detail how to implement buttons, text boxes, and
other onscreen components. Also, the graphical components themselves con-
tained a lot of common states and behavior, such as particular sizes, shapes, col-
ors, positions, or scrollbars.
 
Search WWH ::




Custom Search