REVIEW - Practical C++ Programming


Title:

Practical C++ Programming

Author:

Steve Oualline

ISBN:

Publisher:

O'Reilly (2003)

Pages:

549pp

Reviewer:

Paul F. Johnson

Reviewed:

August 2003

Rating:

★★☆☆☆


The second edition of any book should really be fixing the problems of the first edition. This book breaks the mould and even makes some of the problems worse!

It is difficult to say where this book is of any real use to someone starting programming. The code examples are incorrect, descriptions are incorrect (or glib or plain wrong), end of chapter exercises don't bear fit the chapters (material not covered in the chapter or just unclear) and there is a lot in there that shouldn't be.

A book on C++ programming should concentrate on the language, not extensions (w_char and w_string appear nowhere in the standard), IDEs, makefiles or the compiler. None of these have anything to do with the language, so why does this book spend any time on them? Completeness? Well if that is the case, why before the shots of the Borland IDE, is there a standard "Hello World" with the usual int main() and yet the screen shots have #pragma and change the form of int to int main(int argc, char *argv[]) without any explanation? This will only cause confusion to the newcomer.

The use of the C headers are confused. While cstdlib is used correctly, whenever assert is used, the text has #include assert.h?

One of the most powerful aspects of C++ is that of namespaces - yet the subject is glossed over. Namespaces may not be easy but they are essential. The std:: namespace can be missed if you're not careful!

Possibly the worst part of the book are the number of broken code examples. This is a beginner's book. The last thing they want is for the code to result in compiled binaries that give incorrect results. Very near to the start (shortly after the float variable type is introduced, there is a code example for calculating the area of a triangle. The formula given is

int area = (height * base) / 2;

Okay if height and base result in a number divisible by 2 and are integers. Failing that, the answer is incorrect. Why did the author not just define area as a float (or better still, a double)?

More of these elementary errors follow...

Examples with main as the first function calling other functions which have not been prototyped before hand, using global variables for no apparent reason and a glossing over of for.

Almost as bad as the code errors is some of the text.

Take the following

#include iostream
// This function won't work
void inc_counter(int counter) {
++counter;
}
int main() {
int a_count = 0; // Random counter
inc_counter(a_count);
std::cout a_count '\n';
return (0);
}

Firstly, all of the above is valid code. The inc_counter function does work. It works perfectly. If a debugger is run in conjunction with the compiled code (which the book later recommends), then in the

inc_counter
function, the debugger shows counter has been incremented. a_count is not a random counter. It's a variable. For it to be a random counter, it has to be set to a random value.

What the author is meaning to say is that the code does not work as was intended. That does not excuse the fact that his use of terminology was wrong. This happens quite a fair bit as well, so it is not an exception, it's almost the rule!

The programming exercises seem to be answered at the end of the chapter as the numbering is the same. Hmmm. Hold on, these are not the answers to the same numbered questions, even though it says they are the answers to the questions.

Programming style is highlighted throughout the text with such gems as

Now consider this program fragment:
if(count  10)   // If #1
if ((count % 4) == 2) // If #2
std::cout "Condition : White\n";
else // indentation incorrect
std::cout "Condition : Tan\n";

There are two if-statements and one else. To which if does the else belong to? Pick one


1. it belongs to if #1
2. it belongs to if #2
3. you don't have to worry about this situation if you never write code like this.

The book's answer : 3. The correct answer is 2.

While 3 is partially correct, it doesn't help a beginner as the answer isn't actually given.

All of these problems were up to Chapter 9 - and I've only highlighted them in general! I cannot bear to read past there as this book should be firmly consigned to the book shop shelf to gather dust. Any beginner who has bought this should use it to prop up an uneven bed and get hold of a good C++ beginner's book. [Or take it back to the bookshop and demand a refund. FG]

While it is not the worst C++ beginner's book (I still believe that honour goes to Herb Schildt who's crimes against good programming techniques and correct code can not be over expressed), it is far down the list. Even the latest edition of C++ for Dummies is better. [Actually I think it is much better but that is personal opinion. FG]

A definite blot on the O'Reilly book portfolio.


Book cover image courtesy of Open Library.





Your Privacy

By clicking "Accept Non-Essential Cookies" you agree ACCU can store non-essential cookies on your device and disclose information in accordance with our Privacy Policy and Cookie Policy.

Current Setting: Non-Essential Cookies REJECTED


By clicking "Include Third Party Content" you agree ACCU can forward your IP address to third-party sites (such as YouTube) to enhance the information presented on this site, and that third-party sites may store cookies on your device.

Current Setting: Third Party Content EXCLUDED



Settings can be changed at any time from the Cookie Policy page.