|
| Order on Amazon |
| Errata |
| Bibliography |
|
Only five months after hitting the shelves, C++ Coding Standards is already extremely popular worldwide, and its recognition is steadily increasing. As of April 3rd 2005, C++ Coding Standards is being translated in ten languages. Translations to Chinese Simplified (China), Chinese Traditional (Taiwan), Czech, and French are already underway. (Also, good news for English language readers in India—a low-cost English language reprint will soon be available.) Translations to Hindi, Hungarian, Japanese, Korean, Polish, and Russian are coming soon.
C++ Coding Standards has had a long genesis. The one thing that makes it extremely hard to write about coding standards is that it's very hard to please everyone. How could one ever find the recipe to those 101 rules that most everybody would agree with? It took Herb and Andrei two years to figure that out. To shed light on the book's approach, below is an unedited fragment from the manuscript's preface. The fragment didn't make it in the final book for space reasons, but it is nice and well-written (or so the authors think!), and gives a good idea on the essence of the book.
Here’s a little story that we hope will shed light on our approach in writing this book. The scene is a pub. At a corner table sit four people, variously dressed in period costume. By their conversation it is apparent that they are writers, and they are discussing the best way to write.
On the left, Edgar Allan Poe argues fervently, if with somewhat morbid imagery, in favor of a romantic, vivid style. To his right, Marcel Proust holds forth in favor of long, baroque sentences, full of rhythm, breadth, and color. Facing them, Hemingway speaks tersely, and would prefer a short, stylistically Spartan style, almost like a newspaper column. None questions that the others are also great writers, or that the others' styles are wrong, but each revels in the creative expression natural to himself.
It is at this point, partway through the discussion, that the fourth person at the table piped up: “You know what I think about style? Forget grammar. All those pesky rules to follow. I can get my point across even when I don't follow grammatical rules too much, so they're not really necessary. People should be able to figure out what I mean. And what's the deal with vocabulary, anyhow? If I need to say ‘big,’ I say ‘big,’ and if I need to say it again, I'll repeat ‘big.’ All those synonyms are snooty. And while I'm at it, I don't care much for punctuation either. I use it only when things would be ambiguous, otherwise why bother.”
The foolish man is not allowed to go on for very long before Poe, Proust, and Hemingway dump beer on his head. Even though the three masters prefer different styles, they would be equally disapproving of the fourth's repudiation of all rules. You have to know what the rules are, after all, before you know when and if to (rarely) break them.
We believe that all good writers obey many good rules in their work, and yet such good rules don’t make them feel constrained. And we believe this principle applies equally to writing software as it does to writing the classic novel.
Our goal in this book is to find those things that form the fabric of good code, no matter the style. We hope that you will not find in this book any rules that would make miserable a teammate of yours who’s a Poe, Proust, or Hemingway of coding. They are intended to be the basic rules of grammar, of vocabulary, and of diction for writing sound software in C++.
A problem with code (as opposed to prose) is that it is ultimately consumed by a machine, and some people use “well, it works” as an implied and irrefutable argument of wellness. It is not.