Home Page -------------------
[Home Page] - [Reviews Main]
-------------------

Book Review
C++ Programming Style by Tom Cargill
Recommended
ISBN: 0-201-56365-7       Publisher: Addison-Wesley       Pages: 233pp       Price: £19-95
Categories:   style     advanced c++     writing solid code    
Reviewed by John Washington in C Vu 5-4 (May 1993)
When was the last time you found a bad book by an author from AT&T? I can't even think of one. Try another test: look along your bookshelf. Surely at least some will be by Kernighan, Ritchie, Plauger, Stroustrup, Bentley or others employed at some time by AT&T (if not I suggest it's time you got a new bookshelf).

Add Cargill to that list of fine authors. Authoritative, readable (preferably more than once), yet never patronising, never boring and not a single example of those jokey gee-whizz "Haven't you done well, go and get a cup of coffee!" lines so beloved of many American authors.

On seeing the word 'style' in the title, you might expect this book to tell you how to indent your code, whether to write "char* str" or "char *str", or how to choose meaningful names for your identifiers. In which case you'll be momentarily disappointed, for the aspects of style covered here are much more fundamental.

According to the jacket, this book will help the professional programmer design and write better C++ programs. Amateurs too, I hope, but clearly the serious amateur, already familiar with the basics of C++. This is not a C++ tutorial, rather a book to read at least several months after you've started on C++, when you're comfortable about terms such as classes and member functions, derived classes and virtual functions. Even if you need a reference manual to write such code, you should at least be able to read an example without going into shock.

The theme of the book is programming-in-the-large, encouraging design and coding of high quality. Each chapter takes a small program (typically a couple of pages) and reworks it. Mastering the complexity of designing a large program is very different from writing a small one. At the outset I was sceptical whether a book using short examples could teach much of relevance to large-scale design. I have to eat my words, for I now feel the examples are ideal. On occasion I anticipated the discussion and improvements, then found that the story was only just beginning, and that the issues were far deeper than I'd imagined. This is a book that can be read with reward by a wide range of C++ users, and I expect to return to it to reread all or part, as I progress.

As an indication of the book's aims, I can't do better than quote the second paragraph of the introduction: "Each major lesson learned from studying the programs is captured in a rule of thumb. The nature of the rules varies widely. At one extreme, there are specific, technical rules about avoiding identifiable language pitfalls. At the other extreme are rules that offer guidance on forming abstractions and their relationships in object-oriented programming. All the rules are germane to some aspect of production C++ programming".

Chapter 1 concerns abstraction, using an example showing inheritance and (rather a lot of) virtual functions. It could almost have come out of one of those C++ tutorial texts that construct examples to show the facilities of the language but leave you unsatisfied as to why these facilities were used. Even such an apparently trivial example is reworked several times and results in no less than five "rules" or guide-lines. Now I understand why I use virtual functions sometimes and not others, something I'd been doing by gut feel before.

Subsequent chapters cover consistency, unnecessary inheritance, and virtual functions.

You probably understand some of the ideas of operator overloading even if you've never used it. After reading chapter 5 you'll know that you're not stupid or over-conservative if you've never overloaded an operator in a real- life program. In fact you'll be raring to stick this book in front of the smart Alec down the corridor, the guy whose code you're scheduled to maintain next year.

Chapter 6 takes an example of a wrapper, presenting a set of C library functions as a C++ class. As always, what seems like a fair attempt at the outset turns out to have some snags and room for improvement.

The last three chapters are concerned with efficiency, coupling, and multiple inheritance.

Printed on recycled and acid-free paper, and I hope it will be many years before your copy gets recycled again. In keeping with the feeling of quality and attention to detail, I didn't spot a single spelling error or proof- reading oversight; not often one can say that these days.


Other Authors with the same surname

Cargill
C++ Programming Style by Tom Cargill [Recommended]  (Reviewed Jul 1993)


Last Update - 13 May 2001.

To link to this review, please use the URL: http://www.accu.org/bookreviews/public/reviews/cp/cp000407.htm

Copyright © The Association of C & C++ Users 1998-2000. All rights reserved.

Mirrored from http://www.accu.org/