C++ Programming Style 1st Edition
| Tom Cargill (Author) Find all the books, read about the author, and more. See search results for this author |
Use the Amazon App to scan ISBNs and compare prices.
Editorial Reviews
From the Inside Flap
Modularize. Use subroutines.
This book addresses programming style, with more emphasis on programming-in-the-large, and is restricted to the domain of C++ programs. It is written for the programmer who has learned the mechanics of C++, but is experiencing difficulty in applying the language features - particularly the object-oriented features - to programming problems. Though the discussion is limited to C++, many of the observations about programming are true of other languages. I leave the treatment of language-independent style in-the-large to more ambitious authors.
I have adopted Kernighan and Plauger's method of distilling rules of programming style from the critical reading and rewriting of programs. All the programs used here are taken from textbooks, magazine articles and tutorials on C++ programming. None was created artificially for this work. Some programs are presented exactly as originally published, while others have been altered cosmetically. The alterations range from the correction of in-the-small bugs, which would only distract, to structure-preserving transformations of programs for which copyright was not obtained.
The spirit in which to approach the material is that of an "egoless" code review. We all learn by reading and reviewing each other's programs. The material is not a criticism of individual programmers - it seeks only to differentiate between good and bad programs. No doubt the programs that are presented here as "better" versions have their own shortcomings. The reader is encouraged to examine these programs critically, looking for further improvements in programming style.
0201563657P04062001
From the Back Cover
C++ supports programming-in-the-large, allowing relationships between different parts of a program to be expressed. The scope of C++ programming style therefore goes beyond traditional in-the-small issues which relate to the details of line-by-line coding. This book examines the use of the in-the-large language features of C++, which sometimes confuse even experienced programmers. The author demonstrates that unwarranted use of the more powerful language features may lead to cluttered programs which are harder to comprehend and sometimes less efficient than more straightforward alternatives. Cargill rewrites several programs, using techniques that range from improving consistency to removing redundant inheritance. The presentation simulates a code review, in which readers may independently evaluate and criticize alternative approaches to programming problems, and then compare their analyses with those of the author.
Design and coding style rules are distilled from the examples. Understanding and following these rules will help professional programmers design and write better C++ programs.
A chapter is devoted to each of the following topics:
- abstractions
- operator overloading
- consistency
- wrappers
- unnecessary inheritance
- efficiency
- virtual functions Building on the programming rules introduced in the first seven chapters, Cargill presents a case study in which a single program undergoes repeated transformations that improve its overall quality while reducing its size. The book concludes with a chapter on multiple inheritance.
0201563657B04062001
About the Author
Tom Cargill is a well-regarded expert in C++. While at AT&T Bell Laboratories, Murray Hill, NJ, he was among the first programmers to use C++. He is a columnist for The C++ Journal and The C++ Report, and is also the author of two of Technology Exchange Company's C++ courses. The material for this book was originally developed for tutorials that Cargill has presented at numerous technical conference.
0201563657AB04062001
Excerpt. © Reprinted by permission. All rights reserved.
- Modularize. Use subroutines.
This book addresses programming style, with more emphasis on programming-in-the-large, and is restricted to the domain of C++ programs. It is written for the programmer who has learned the mechanics of C++, but is experiencing difficulty in applying the language features - particularly the object-oriented features - to programming problems. Though the discussion is limited to C++, many of the observations about programming are true of other languages. I leave the treatment of language-independent style in-the-large to more ambitious authors.
I have adopted Kernighan and Plauger's method of distilling rules of programming style from the critical reading and rewriting of programs. All the programs used here are taken from textbooks, magazine articles and tutorials on C++ programming. None was created artificially for this work. Some programs are presented exactly as originally published, while others have been altered cosmetically. The alterations range from the correction of in-the-small bugs, which would only distract, to structure-preserving transformations of programs for which copyright was not obtained.
The spirit in which to approach the material is that of an "egoless" code review. We all learn by reading and reviewing each other's programs. The material is not a criticism of individual programmers - it seeks only to differentiate between good and bad programs. No doubt the programs that are presented here as "better" versions have their own shortcomings. The reader is encouraged to examine these programs critically, looking for further improvements in programming style.
0201563657P04062001
I'd like to read this book on Kindle
Don't have a Kindle? Get your Kindle here, or download a FREE Kindle Reading App.
Product details
- Publisher : Addison-Wesley Professional; 1st edition (August 1, 1992)
- Language : English
- Paperback : 248 pages
- ISBN-10 : 0201563657
- ISBN-13 : 978-0201563658
- Item Weight : 15.5 ounces
- Dimensions : 7.5 x 0.75 x 9.25 inches
- Best Sellers Rank: #3,159,758 in Books (See Top 100 in Books)
- #1,053 in C++ Programming Language
- #7,808 in Computer Programming Languages
- #14,739 in Computer Software (Books)
- Customer Reviews:
About the author

Discover more of the author’s books, see similar authors, read author blogs and more
Customer reviews
Customer Reviews, including Product Star Ratings help customers to learn more about the product and decide whether it is the right product for them.
To calculate the overall star rating and percentage breakdown by star, we don’t use a simple average. Instead, our system considers things like how recent a review is and if the reviewer bought the item on Amazon. It also analyzed reviews to verify trustworthiness.
Learn more how customers reviews work on AmazonTop reviews from the United States
There was a problem filtering reviews right now. Please try again later.
The inferior thinking that confounds the world of programming is that C++ is an easy language to master. Very few programmers have much hope of aspiring to learn even 80% of the language and use it effectively. Thinking otherwise is like saying that everyone who wants to run a foot race can be Jessie Owens. Tom starts by treating readers as programming peers. That alone is an incredible benefit anytime programming is being done. Prima donas and those guys who always seem too busy to provide their "public interface" are the ones to avoid in learning anything of use regarding C++.
I pick up Tom's book every couple of months and browse it. His noted "brevity" is like a good RPG that gives subtle hints that incite thinking for yourself without following what many other books do by drawing a roadmap to one solution that worked for this one situation but may never again apply to anything useful. In my opinion, Tom's "lessons" are appropriately concise.
If you haven't read Tom's book, buy it, read it...if you're serious about your C++ skills. There is a *good* reason why Scott Meyers recommends Tom's book. It is something of a unique and interesting perspective on C++, which is really all that any of us can hope to give back to the language. The book is an interesting, insightful perspective that has pragmatic commentary that will help you be a better C++ programmer. At the last (ever?) C++ World conference in December of 1999, a discussion of which books to read evolved out of some other spew. Cargill's book came up as necessary reading, as it always seems to, for the simple fact that it comes from a respected industry professional with an uncany ability to boil out the meat of the topic without overcooking the stew. C++ is, at least, also an art form. Tom's ability with the art of C++ is inspiring. Scott Meyers is another artist. So is Angelika Langer and Herb Sutter, and Andy Koenig, Stan Lippman, Doug Lea and Erich Gamma and Jim Copelien and numerous others. But, for each of them, there are 10,000 very so-so programmers out there spewing forth complete nonsense. Help de-nonsense your world with Tom's book. One person indicated that it is somewhat stale. It is really like fine wine. It just gets better with age.
The book was published in 1992, so the modern reader will notice the old fashioned C++ - no templates (therefore no STL), no exceptions, no strings, old style .h headers. The implementation of the assignment operator relies on a check for self assignment (rather than merely using it as an optimisation), and it uses arrays polymorphically. Readers of Exceptional C++ and Effective C++ will know that these are not recommended practices in modern C++. However, I assume that you aren't going to read this without a good grounding in basic and intermediate C++ and can spot the parts which require tweaking.
Fortunately, the book is structured as a series of code reviews, so it stands out from the glut of mini-essay type books, and the general principles of class design that the book propounds remain useful. And even fairly advanced programmers probably won't spot all the problems that Cargill highlights, so you'll definitely learn something.
I'm giving it four stars because is still covers a core of C++ that is relevant and you can pick it up cheaply. But don't expect it to be fully up to date.


