Book Reviews - Practical C++ Programming
Practical C++ Programming by Steve OuallinePractical C++ Programming goes through a structured overview of C++ language, focusing on detailed coverage of language features and dispensing practical advice. The book's approach serves a broad audience; its readability makes it a good book for teaching yourself to program, and its depth of coverage makes it a good second or third book for more experienced programmers, as it goes into more detail than a teach-yourself book requires, without being so technical that you cannot read straight through it. In fact, it reads both quickly and well, with anecdotes from some of the author's projects serving to emphasize his points about practical programming. Adding to the readability, throughout each chapter the author scatters miniatures quizzes testing the reader's ability to spot bugs or flawed programming practices; these quizzes range from the simple -- spelling errors, using = instead of ==, for instance -- to the tricky -- macros having unexpected results due to order of operations issues, such as leaving out parentheses. Most examples can be solved within ten minutes, but effectively leave a lasting impression, and help tremendously with the process of debugging code. Practical C++ Programming also uses the examples to reinforce concepts and bring up corner cases that might otherwise be overlooked, and also includes programming exercises at the end of each chapter to provide practice problems for the reader.
Several aspects of this book that differentiate it from other books on programming. In conjunction with its focus on practical advice, Oualline emphasizes the tools of programming, from using help files to debugging tips and a discussion of makefiles and the make utility. Practical C++ Programming also spends a great deal of time on programming design, discussing everything from object oriented and procedural design practice to the more underground design by copy and paste. C programmers will appreciate the chapter on going from C to C++, and even C++ programmers may find it an interesting catalogue of differences between the two languages.
The book covers the full range of basic C++, from variables, control structures, arrays and pointers, to trickier object oriented design issues such as inheritance, virtual functions, operator overloading, and templates. The use of compilers and make files is covered, an entire chapter is devoted to debugging (with a tutorial on using gdb), Oualline includes numerous sections on practical tips, several appendices for reference (though it does lack a catalogue of standard library functions), and several chapters on the use of pointers. Special mention should be made on the very complete section on floating point numbers, which covers their limitations from accuracy, size limits, and speed issues. In addition, Oualline provides a sample fixed point class in the section operator overloading, which helps show the contrasting methods of handling fractional numbers in C++.
The book's material is accurate. The topics are relevant, as demonstrated by the author's coverage of namespaces, the standard template library and relatively advanced and powerful features of C++ such as templates -- all topics you might not find covered in an older work. Code conforms to the latest standards, and avoids common niggling errors such as using void main() in sample programs.
The sample code works except in cases when explicitly used to show buggy code, which he conveniently labels. The examples range from purely practical programming, such as creating a class to handle infinite, resizable arrays, to mathematical, such as using a power series to compute sine (though, for the non-mathematical, it is buried in the appendix). Oualline uses code liberally to illustrate his points, keeping the examples short where possible, but building up to longer sample programs that can be run by the reader. Additionally, in order to demonstrate the use of a common Unix debugger, GDB, Practical C++ Programming covers an entire debugging session that could be used to track down several run-time errors and logic errors in a program.
Stylistically, the book is a good read. Oualline avoids the mistake of trying too hard to make a point except for his overemphasis on commenting, an emphasis that occasionally becomes repetitive. The anecdotal asides often add a touch of humor while (usually) making a point.
Overall, this is a good book for most programmers. For a beginner, this book lays out the practical fundamentals of programming, along with providing information about compilers and other helpful tools that books often skip. For any other inexperienced programmer, the practical tips will go a long way toward improving programming technique. A professional might enjoy the book for some of the anecdotes, but would likely already know both the programming material and the practical advice.