|
T
his
C++ book is unique: published in 1996, it still is the only volume on the
development of large-scale software systems implemented in C++. It describes
how one would use the C++ programming language in a way that scales well
to very large systems. Yet most of the advice presented in the book also
applies to small projects.
Typically, projects expand,
and what started out as a small project often becomes a major undertaking.
Experienced C++ programmers thoroughly understand the C++ language features.
However, as programs expand, different forces come into play; techniques
used to create small programs in C++ don't work when tackling larger projects.
In his book, Lakos distinguishes between physical and logical design issues.
First,
logical design
is about language constructs (classes, functions, and inheritance). It
revolves around questions like: Does a class need a copy constructor? Shall
an operator be a member function or a free function? Shall a member function
be const or non-const, virtual or non-virtual, static or non-static? Logical
design does not address issues such as where to place a class definition.
Unfortunately, as programs get larger, such physical design issues become
more relevant.
Second,
physical design
addresses issues of the physical entities of a system (files, directories,
and libraries). For instance, making a member function of a class inline
forces any client of the class to have seen not only the declaration of
the function, but also its definition. What is affected is the degree of
physical coupling between the class and its clients.
Lakos devotes most of his book
to physical design, explaining techniques for reducing the degree of interdependency
among the physical entities of a C++ system. He discusses the adverse effect
of cyclic dependencies, a symptom of which is that no part of the system
can be understood independently. Cyclically dependent designs are impossible
to be tested modularly, whereas hierarchical designs (for example, noncyclic
designs) are easy to comprehend, test, and reuse. He explains the drawbacks
of excessive link-time dependencies, which are a result of "fat" interfaces
where one class depends on a tremendous amount of code. Link-time dependencies
lead to oversized executables. He also discusses the effect of compile-time
dependencies, such as situations where changing one innocent-looking header
file results in recompilation of the entire system--a costly activity that
in very large systems could take days. Reducing the degree of coupling
therefore is vital to the success of large-scale development.
Lakos's analysis and proposed
solutions regarding physical design are very detailed (about 450 pages)
and distinguish the book from other C++ publications. At times, this discussion
may seem overdeveloped, but in multimillion lines-of-code programs these
considerations indeed are vital. However, in an ideal world, we would expect
the development environment (compiler, linker, run-time system) to take
the burden of physical design issues off our shoulders. As C++ programmers,
we want to concentrate on logical design. Lakos discusses logical design
in a 200-page section of the book, and many of the topics discussed there
can be found in other books, as well. Yet this section is recommended reading
for C++ programmers who want to gain a deeper understanding of the tradeoffs
of C++ language features.
Large-Scale C++ Software
Design
is an advanced text that is unique in covering physical design
issues relevant for very large systems. It is also valuable for smaller
projects because the suggested techniques are good practice and scale well.
It's a pity that the book covers only "classic" C++ and does not consider
programming with templates and/or exceptions. Let us share with you what
Lakos replied when we asked him what he thinks of the impact of these "new"
language features on large-scale systems: "That is something my children
or grandchildren will be writing books about. Right now, nobody has enough
experience with templates and exceptions to understand the full range of
consequences." Well, right he is!
Angelika Langer
develops
and teaches classes on advanced C++, STL, multithreading, internationalization,
and Java. She has served on the ANSI/ISO C++ Committee since 1993.
Klaus
Kreft
is a software architect and consultant with more than a decade
of experience in industrial software development. He works for Siemens
Business Services in Germany. Langer and Kreft are working on a book about
standard C++ iostreams and locales and are columnists for
C++
Report
.
|