[comp.lang.c++] C++ book review

bs@alice.UUCP (05/05/88)

John Carolan (of Glockenspiel Inc.) wrote this review for the EUUG
(European UNIX Users' Group) newsletter. His newsfeed is broken so
he asked me to post it here.

********

"An Introduction to Object-Oriented Programming and C++"
by Wiener & Pinson
Addison-Wesley
ISBN 0-201-15413-7

The book presents a good introduction to the jargon of OOP, at 
least until it gets to page 8.  On page 8 it presents the first 
of many serious mis-understandings.  The book tries to describe 
the process of designing an inheritance hierarchy.  It uses for 
an example an automobile with components such as engine and gear-
box.  It implies that engine and spark-plug should be derived 
from automobile, which misses the following point:  Functional 
decomposition of a problem and class derivation are orthogonal 
es which deal with human interface 
to some extent would be more interesting and could show how OOP 
assists consistency in the human interface.

As a textbook on C++, W&P has serious flaws.  I counted over 
twenty errors.  Here's an example from page 126:
"The public qualifier in the derived class definition indicates 
that objects of the derived class can use all the methods of the 
parent class, unless these methods have been redefined in the 
derived class."

Stroustrup's book may be hard going, but at least it is accurate.
Nowhere does W&P offer a Rosetta Stone for translating between 
C++ terminology and OOP terminology. It calls all data members of 
classes 'fields', for example.  Now, in C and C++, only members 
with the form < declarator : constant-expression > are called 
fields. It confuses objects with classes and declarations with 
definitions in several places.  For example, on page 21:
"The operators in the cin, cout and cerr classes can be 
overloaded within a programmer-defined class."
W&P is very misleading on the interaction between typedef, 
inbuilt types and classes.  The book omits several important 
features of C++.  The most noticeable being programmed assignment, 
programmed conversion, coercions and pointers to member 
functions.

The last chapter contains three example programs.
The first is a spelling checker.  In it, there is a class 'word' 
which has a member function 'open_file()'.  Now, how can a word 
have a behavior such as open file?  In a book which attempts to 
instruct people on OOP, this is unacceptable.  There should be a 
class such as WordFile on which Word is not dependent.
The second example is a golden oldie from Simula which does an 
event-driven simulation of queues in a bank.  The book follows 
the OOP approach nicely until it comes to the human interface.  
Then ZAP!, objects are nowhere to be seen.  The output from the 
program is very difficult to interpret simply because the OOP 
paradigm gets dropped.

The third example is a simple function interpreter.  It parses a 
calculator language using an expression tree and it does syntax 
checking using a finite state machine.  The syntax checker does 
not re-use any of the code in the parser.  However, the program 
is riddled with friend declarations, which weaken the 
abstractions unneccessarily.  The finite state machine declares 
each state as a separate class with one instance, which 
immediately rings warning bells.  Well, the warning bells are 
correct.  It is simpler to code this particular FSM in a table-
driven form.  The classes should be state transition tables, not 
states.  If you are in any doubt about my criticism of this 
example, then repeat the following exercise:  Add a unary minus 
operator to the Function Interpreter and count in how many places 
you have to change the code.  Lastly, this example restricts the 
user interface just because W&P want to use operator overloading 
in a place where it is not appropriate.  The user of the program 
types a formula where the arguments are mentioned explicitly.  
Each invocation of the formula asks the user to say how many 
arguments again.  Not a good user interface.

In summary, the book covers neither OOP nor C++ very well.  It 
needs a lot more proof reading by practitioners of C++ before I 
would recommend it to someone learning C++.