Stephen C. Dewhurst: C++ Common Knowledge
At first you might think this set of 63 articles ("items") is another collection of recommended programming practices, like the respected volumes by Scott Myers and Joshua bloch. On further examination, however, you note a fundamental difference. While Myers and Block emphasize good programming practice Mr. Dewhurst tells us mostly how things work. Unfortunately, he doesn't do that very well.
Item 1, "Data abstraction", made a strong favorable impression. It begins (p. 1) with a warning against an all-too-common bad practice:
"Never, ever, simply provide a bunch of get/set operations on the data members of [a class]."
Readers of this web site know that I've been campaigning against just that deplorable but growing practice, so I was delighted by Mr. Dewhurst's concurrence, even if he didn't really explain it.
The titles of next three items are startlingly broad:
Mr. Dewhurst introduces highly specialized techniques with no explanation at all of why one would need or want to use them. For example:
"If you don't like the way standardbut gives the reader no clue as to why one might not "like" the standard operations' behavior or what advantages a user-defined alternative might offer.
operator deleteare treating one of your class types, you don't have to stand for it."
The author notes in the preface (p. xii) the need for rigor:
"The author's ignorance of these complexities could result in an uninformed description that could mislead the reader "leading us to expect the most careful attention to accuracy. But then:
cout << "next two in series: " << fib() << ' ' << fib() << endl;falling into the very trap that other writers take pains to warn against. Which call to fib in the same expression will your compiler evaluate first? Take your chances.
void average( int ary );
"It's often necessary for correctness, and occasionally more efficient, to perform a check for assignment to self, that is, ensure the left side (In fact, the accompanying code he recommends here is rarely if ever necessary or desirable, and may sometimes lead to a less efficient implementation. See Assignment to Self Overkill .
this) and right side . . of the assignment have different addresses."
Those are minor goofs, but once the reader's trust is undermined he or she is likely to be skeptical of the author's other examples, especially those with vague explanations.
Return to book reviews.
Return to table of contents.
Last modified July 10, 2005