B
arbara
Liskov and John Guttag's book has a somewhat misleading title.
Program
Development in Java
suggests that it provides an introduction to the
Java programming language. Nothing could be further from the truth. This
is
not
yet another indistinguishable introduction to Java. It's
a really good book on abstraction and program design.
In
fact, the subtitle "Abstraction, Specification, and Object-Oriented Design"
describes the book more precisely than the actual title does. It explains
how to find abstractions, how to design and describe them, and how to express
them in terms of an object-oriented programming language. The book focuses
on the decomposition of complex programs into smaller subproblems and on
organizing a large program system as a collection of well-chosen abstractions.
The
programming language chosen for presenting the code samples is Java, incidentally.
For this reason, the book also gives an introduction to the main features
of Java. But it is by no means a typical Java textbook. You do not need
any previous Java knowledge in order to read, understand, or benefit from
this book. In fact, you can learn the basics of Java while improving your
knowledge of modular, object-oriented design.
The
first chapters of the book focus on abstraction mechanisms. These chapters
discuss procedures and exceptions, data abstraction, iteration abstraction,
families of data abstractions, and polymorphic abstractions. It answers
such questions as, What exactly is an abstraction? How do we invent good
abstractions? How do we properly describe or specify an abstraction? How
do we implement an abstraction? How do we organize abstractions into families?that
is, into type hierarchies? (In the chapter on type hierarchies, you'll
find the substitution principle for subtype/supertype relations that carries
Barbara Liskov's name?known as LSP, the Liskov Substitution Principle.)
The
second part of the book is devoted to "programming in the large"?that is,
design and implementation of complex systems in a modular way. The chapters
describe all stages of the development process from requirement analysis
over iterative program design to implementation and testing.
A third
part (just one chapter) explains design patterns not covered earlier in
the book. It is a brief introduction to patterns and does not try to be
comprehensive. For a complete discussion of this material, other books
such as
Design Patterns
by Gamma et al. must be consulted.
Program
Development in Java
is a remarkably well-organized and very readable
book. We particularly like its systematic approach. Here are a few examples
to illustrate what we mean:
-
Very early
in the book, Liskov and Guttag discuss the distinction between mutable
and immutable objects, an important issue that's far too often neglected
in class design, partly because Java is not the ideal language for expressing
the concept of (im)mutability.
-
The section
on data abstractions classifies operations into four categories: creators
(produce new objects from scratch), producers (take other objects of the
same type as input for production of new objects), mutators (modify the
state of their object), and observers (provide information about the state
of their object). Experienced programmers often intuitively organize their
class declarations this way and Liskov & Guttag provide the systematic
foundation for this habit.
-
In the
section on exception handling, there is a clear classification of two possible
reactions to an exception: reflecting (propagating the exception up to
another level in the call stack) and masking (handling the exception and
continuation with normal control flow). Again, an important distinction.
-
In the
section on type hierarchies there is a clear distinction between an object's
apparent type (the static type deduced at compile-time) and its actual
type (the dynamic type determined at run-time), which is fundamental for
a proper understanding of method dispatch.
Throughout
this book the terminology is crystal clear and is often summarized in sidebars.
Even so, the actual terms the authors choose are sometimes debatable. For
instance, it's not too common to talk of "reflecting an exception"; it's
more commonly called "propagation." Methods that they call "observers"
are often called "inspectors" in practice. Despite these potentially debatable
terms, the underlying principles are, without doubt, important in software
development and this book does a good job in clearly communicating them.
Program
Development in Java: Abstraction, Specification, and Object-Oriented Design
should be interesting reading to programmers who want to improve their
knowledge of object-oriented design and implementation, but we recommended
it equally to beginners who need to learn the principles of object-oriented
design and implementation from scratch. It is probably more useful to beginners
anyway, because much of the discussion in the "programming in the large"
part encompasses the basics of the development process, which a seasoned
practitioner would be familiar with.
Angelika
Langer
develops and teaches classes on Java, C++, multithreading, and
internationalization. She is an internationally recognized speaker and
served on the ANSI/ISO C++ Committee from 1993 to 1998.
Klaus Kreft
is a software architect and senior consultant with 15+ years of experience
in industrial software development. He currently works for Siemens Business
Services in Germany. Langer and Kreft are authors of "Standard C++ IOStreams
and Locales" (Addison-Wesley, 2000) and are columnists for the C/C++ Users
Journal.
|