I didn't start off hating Oualline's Practical C++ Programming (PCPP), but grew more and more frustrated trying unsuccessfully to learn from it. Eventually I bought Stroustrup (not easy reading, but thorough and reliable), then came back years later and realized how incompetently-written PCPP is. Detailed, well-argued reviews panning PCPP have been available online for more than six years. I'm only investing time to write this review because I see, with some shock, that in 2007 one can still find positive reviews. PCPP is a black mark on an otherwise excellent series of books. If discontinuing the volume isn't possible, the title should be changed to the more accurate ``C++ syntax for C programmers'' and the back cover comments, some of which are baldly false (``...a complete introduction to the C++ language for the beginning programmer...''), should be rewritten.
PCPP garners opinions at both ends of the spectrum, and few in between. In fairness, there's truth in the positive reviews: Parts are written in a lively style, and the book might be useful to a C programmer who needs to port code quickly to C++ syntax. If you consult the book as a guide to quick-and-dirty porting of C to C++, or as a first introduction to the process of programming (and you read only Chapters 1-3 and 7), you may have an acceptable experience. If you intend to learn C++, not merely the syntax, but the overall philosophy, I'd recommend books by Scott Meyers, Stephen Dewhurst, Herb Sutter, or Bjarne Stroustrup. Oualline's PCPP is a terrible C++ book, introductory or no.
As others have mentioned, PCPP is filled with typos. According to Oualline, this is a feature, not a bug, since a programmer must be able to spot errors in code. Unfortunately for the C++ newbie, this reasoning presumes one already knows the language.
The book exhibits (and therefore disseminates) numerous, fundamental misunderstandings of C++ features, design, and programming philosophy. Why even mention macros and the pre-processor, structures, unions, and bitfields in a C++ book that neglects data encapsulation, object-oriented design, memory management idioms, virtual functions and inheritance, templates, and other basic language features and philosophy? These are not merely consequences of the publication date.
Flipping casually through my own well-marked copy of PCPP, without searching for particularly egregious lapses of accuracy and clarity, I found dozens of gaffes. Chapter 5 discusses arrays, while the STL provides less error-prone methods of handling strings and a variety of list-like structures. And telling the reader to use fixed-size arrays, strcpy, et. al?! Hard-coding container sizes is not merely gratuitous rigidification; it's an invitation to buffer overflows and other memory-corrupting bugs.
The mis-explanations of references (combined with ampersand typos) are a pedagogical disaster. The first mention (p. 137) refers the reader to Chapter 4, where references do not appear. Oualline promptly claims, ``For global and local variables, reference variables are not very useful. However, when used as parameters they take on an entirely new meaning.'' For starters, good C++ uses const references to avoid unnecessary copying. Second, functions that modify their arguments are bad O-O style; the reference parameters should be private members of a class. Said class should provide a method the modifies the data. Open to a random page of PCPP and you're likely to encounter one or more errors of comparable magnitude.
It's difficult to understand how a competent C++ programmer could have written Chapter 13, which introduces classes. On p. 198: ``You start a stack design by designing the data structure.'' No, in an O-O language you start by designing an interface.
It gets worse. On p. 201: ``The design [of a stack] states that only the stack should have access to these fields, but there is nothing to prevent rogue code from modifying them.'' (Emphasis added.) Oualline's seemingly flip use of the term ``rogue code'' suggests malware. In reality, a class's internal data should be private to break unnecessary ties between distant parts of a program. One of C++'s great strengths is the compiler-enforced separation of interface and implementation. Oualline's failure to mention this basic features tells me he doesn't understand C++ at a level higher than basic grammar.
PCPP pretends to be a complete introduction to C++, but in fact emphasizes C's features, discusses only procedural programming, and fails to explain object-oriented programming (classes and inheritance) accurately or even to mention generic programming (templates). Oualline is a C programmer who believes he knows C++ because he can write C using C++ syntax. A reader whose sole exposure to C++ is Oualline's book has no meaningful knowledge of the vast differences between C and C++.
|