The Codesmith's Library
Taligent's Guide to Designing Programs
Well Mannered Object-Oriented Design in C++
Written by Jorge Martins
In The Codesmith's Library, we focus on development books and materials. Pick up whichever book strikes your fancy, and join the growing group of people following our programming columns.
Please send your comments and thoughts so that we can make this column what you want it to be.
Taligent's Guide to Designing Programs
Well Mannered Object-Oriented Design in C++
This book is a collection of guidelines and conventions used in the Taligent Application Framework, published with the intent to help professionals outside Taligent. Most of the rules apply to any C++ development system, so if you are looking for a set of C++ programming guidelines, this book might do the trick. Besides, if you already have a working standard, reading this book might help you improve it. This book, isn't meant to be read from cover to cover. Instead, the reader should pick a section and explore it. I found an on-line version of the book here, for free, or so it seems. On a side note, Taligent (at the time, a joint effort between IBM, Apple and HP) is now a fully owned IBM subsidiary and is focusing on Java (surprisingly <g>).
Brief Contents Contents Preface 1. Introduction Architectural goals Object-Oriented architecture Putting it all together 2. Object-Oriented design guidelines Classes Abstract base classes Inheritance Multiple inheritance Performance by design Common design problems and pitfalls 3. C++ Programming conventions The C++ standard Source file conventions Name conventions Class definition conventions Type declaration conventions Arguments and function results Reference and value semantics: C++ versus everything else Static object constructors The C preprocessor Things to avoid 4. Taligent environment programming conventions Taligent libraries Storage management philosophy Shared libraries Binary compatibility considerations Inline functions Virtual functions Friend functions and classes Exception handling Portable hash Equality 5. Taligent environment programming tips and techniques Surrogate objects Storage management issues Concurrency and shared libraries issues Miscellaneous programming tips 6. Portability issues Language and hardware assumptions Synchronization Portable data Assembly language Nonportable code A. Class templates Definitions and conventions Sharing class template implementation The example class: an owning stack Sharing the implementation through private inheritance Sharing the implementation by delegating to a member Further reading Bibliography Index
Before the preface, there are two tables of contents. The first is "regular". The second is almost a mini version of the book. After I read the whole book and had any kind of doubt this "expanded" contents proved to be enough to revive my memory. This is a very nice touch. Very handy.
The preface (written by David Goldsmith) advocates object-oriented design is best learned from building systems. He also states that, although this book is specific to the Taligent Application Environment, this is an advantage because most of it applies to any C++ development environment, and other developers might gain from their empirical knowledge.
Chapter one presents the architectural goals Taligent pursued with their Taligent Application Environment and the principles behind them. Basically, the reader is encouraged to use objects wherever possible. According to Taligent, frameworks are the foundation of object-oriented technology.
Chapter two covers general object-oriented design guidelines. Before anything else, the reader is advised to have a solid understanding of what classes are before proceeding. The bibliography lists books on that subject. The chapter begins with a set of guidelines used to build individual classes and goes on to techniques which make Abstract Base Classes well defined. Inheritances issues follow, including multiple inheritance, a tricky subject. Next, we have performance. How to attain good levels of performance without writing everything in assembly and preserving good programming style. The chapter ends with common design pitfalls. Problems identified as "Object bloat", "Structification" (excessive getters and setters) and "Modulitis" (former C functions packaged hastily as members of a C++ class) are exposed, amongst others.
Chapter three deals with programming conventions specific to the C++ language that cover a wide range of material. Source file conventions such as proper use of comments and header file inclusion safety lead the way to a comprehensive set of C++ naming conventions. Follow class definition conventions, type declaration conventions, arguments and function return values conventions. Next, we have a section dedicated to references and pointers, with advice on what to use in each case. There's a small section about static objects and their dangers. The reader is then warned not to use the C preprocessor and alternatives are presented, such as inlines instead of function macros. Finally, there's a section devoted to questionable coding practices such as using gotos.
Chapter four introduces programming conventions specific to the Taligent Application Environment. This probably sounds of little use to anyone outside Taligent. Wrong! Although there are many references to classes specific to the Taligent environment, much can be learned in this chapter. We are advised to use Taligent classes instead of ANSI C libraries. If you are using decent class libraries such as Open Class, I'm sure that rule still applies. Follows a set of storage management guidelines, a subject that is labeled as "a real burden". Next, there are guidelines to address shared libraries concerns and a section about binary compatibility issues. Inline functions, highly problematic in these cases have their own section too. Virtual functions, essential in object oriented programming using C++, are discussed in a section where the reader is offered advice on when to use them and how to avoid common problems. Friend functions are considered questionable but an alternative is provided, as usual in this book. Again, the reader is encouraged to confer with a Taligent architect in these cases. Most people can't do that, so it's time to think it over again, I suppose. The Taligent Application Environment, as any well designed C++ class library uses exceptions, not error codes, to deal with unusual circumstances. The reader is encouraged to read Stroustroup's explanation of exception handling on "The C++ Programming Language" as well as some pages of a Usenix C++ Conference Proceedings paper. There's a quick review of how exceptions work and, again, a set of guidelines, things to avoid and things to do. Next, there is a section regarding portability issues of a specific Taligent construct, the Hash. The chapter ends with a discussion of equality issues. RTTI solves some of the problems reported but, as this book was first printed in 1994, it wasn't supported then.
The fifth chapter covers tips and techniques Taligent engineers learned with time and experience. Again, these tips are specific to the Taligent Application Environment but it doesn't hurt to take a peek. Topics such as concurrency are valuable to anyone, even if the specific classes mentioned aren't available to most people.
Portability issues make their appearance in last chapter (six). The reader is provided with a set of assumptions that are safe, in the C and C++ languages but warned with a set that it isn't. Anyways, it is best not to assume anything. Assembly language is strongly discouraged. Even if there is a situation where non-portable code is absolutely necessary, some steps are provided to attenuate the problems it might generate. The reader is, again, advised to contact a Taligent architect on these tricky subjects. Non-Taligent programmers should think things over, again.
There's an appendix with enough information to form a chapter on Templates, which by their nature tend to bloat code, so we are presented a set of guidelines, with the intent to increase code maintainability and insure smaller memory footprints. This appendix is full of examples and ends with further reading suggestions.
The book ends with a small commented bibliography and a standard index. The bibliography even lists Scott Meyers's Effective C++, a similar but better known book.
Taligent's Guide to Designing Programs - Well Mannered Object-Oriented Design in C++ is an outstanding book, concise and thorough. Even if some parts are specific to the Taligent Application Environment, much can be learned from this book, which by the way, is very inexpensive.
I give it an A.
Taligent's Guide to Designing Programs - Well Mannered Object-Oriented Design in C++, Taligent
Our Bookstore has reviews and links to Amazon for all books we have reviewed in the past, as well as several books waiting to be reviewed, and others which we recommend.