Along with many other managers and software designers, I am painfully aware of the problems software engineering is facing today. This book presents design and coding techniques which can lead to an improvement in both productivity and quality of the resulting software, especially on larger projects. The book deals with the basic questions of class design and interaction, and it should be of interest to students and experts alike. Numerous examples demonstrate the ideas, with emphasis on complex problems which occur in real-life applications. You should have at least some knowledge of the C++ language before you start to read; this is not a C++ textbook.
This text evolved through several stages before it took on the form presented here. Starting from my observation that a number of negative experiences with early C++ projects were caused by poor class organization, I originally planned to focus the book on C++ and large projects. The idea was to discuss code organization issues that do not show up in small examples usually published in books. Later on, I decided to include a discussion of data persistence, because most larger projects need this difficult-to-implement feature and there is a close connection between pointer-based data structures and persistent data.
During the initial planning of the book, my friend Craig Hubley suggested that several case studies describing technical details of large application projects would be of interest to many readers, and would complement the text well. Three coauthors willing to contribute large case studies on interesting commercial projects joined the project: Jim Coplien (AT&T prototype switching system), Rob Bartel (Mentor Graphics CAD database), and Bill Welch (Wall Street financial application). However after the first drafts were in we discovered that we were emphasizing entirely different issues--from the organization of C++ code to the organization of human groups--and we abandoned the idea of collaborating.
The discussions with the three would-be coauthors greatly improved my original text and caused me to add entire chapters, and many examples, and to more thoroughly explain many other parts. Thanks to these discussions I was motivated to collect six shorter application studies which would demonstrate the use of programming techniques described in the book. These short case studies eventually became Chapter 9. The text was also enhanced by the comparison of two different library styles, including an example coded by Keith Gorlen (now Section 6.3). The title gradually evolved to C++, Large Projects, and Persistent Data.
The final stage began with an observation from Marjan Bace of Manning Publications that there may be similarities between what I was calling data organization and the concept of design patterns recently discussed at the OOPSLA conferences and in a couple of soon-to-be-published books. It turned out that he was right. The two concepts that are soon to be published are very close, though not identical. However, I could not find in the literature anything equivalent to what I originally called hyper-class: a special class which represents an entire pattern. This lead to further research and private discussions with Ralph Johnson, Erich Gamma, Bruce Anderson, Craig Hubley, and many others. Thanks to their generous input, I was led to the final form in which to present pattern classes (Section 2.5 and 2.6) as well as to the final title.
A discussion with Trygve Reenskaug of Taskon in Norway, centered on the differences in approaches to programming in C++ and in Smalltalk. From this comparison, we hoped to discover possible ways to improve the C++ coding style. The idea sounded interesting, and with Trygve's and Craig's help, we added Section 6.4, including a full Smalltalk example.
The main advantage of pattern classes is the de-coupling of application classes. In situations that traditionally lead to large clusters of mutually dependent classes (traditional frameworks), pattern classes allow you to test and compile most classes independently. Also, each pattern can be tested as an independent unit.
This book combines ideas from different software fields, and contains numerous nontrivial examples. You will discover several common denominators: Class organization and communication (patterns), class relations, and the management of pointers. Even though this book took more work than a volume of its length should take, it was fun to write. I hope you'll find it equally entertaining to read. I tried not to hide controversies where they exist, and to be honest about problems that have not yet been solved.
I would like to thank Marjan Bace for his patience, understanding, new ideas, continuous support, and guidance; Craig Hubley for his readiness to help with many technical problems; and Judy Melanson for her able text processing and formatting. I would also like to thank all three reviewers of the final manuscript, Delano C. Stevens (GTE), William E. Bulley (Ann Arbor Computer), and Ed Schiebel (AT&T Bell Laboratories) for their valuable comments, as well as Margaret Marynowski and Maryla Sikora for their fine work in copyediting the manuscript and typesetting the book. Some readers may not be aware that the production of most books involves entire teams of dedicated specialists who, often anonymously, contribute a great deal of experience and effort to the product which, in its final form, carries only the author's name. This book is no exception. This entire project would have been impossible without the support of my programming family. My son Martin edited both versions of the entire manuscript and, without a single complaint about my excessive working hours, my wife Hana helped me by discussing countless technical and conceptual issues that arose in the project. Addison-Wesley has provided an e-mail address for communication with the author, or if you would like to be placed on a mailing list. Please send mail to soukup@aw. Code from this book is also available via ftp aw in the directory awputer.science.soukup, or on a diskette from Addison-Wesley.
Jiri Soukup 0201528266P04062001
issue in large project development, in testing, and in maintenance. Taming C++ takes a fresh look at the complex organization typical for large C++ systems and shows how this problem can be minimized by avoiding cyclic dependencies between classes, and by implementing the original object-oriented design so that it remains visible in the final code. This book shows you, through extensive examples, how to design and write C++ code using a new type of class--the pattern class--which helps you produce layered class organization with limited cyclic dependencies. The book then focuses on another problem of large project development--persistent data--integrating it with its general approach and providing copious implementation details unavailable elsewhere. Features
- Emphasizes code readability achieved through better class organization.
- Teaches how to improve software architecture.
- Shows how pattern classes encapsulate the high level object-oriented design.
- Promotes layered structuring of class relationships.
- Compares and contrasts design methodologies, class libraries, approaches to testing, and treatments of persistence.
- Explains how persistent data can be used as fast databases (frameworks) residing virtual memory.
Taming C++ is written for programmers, designers, and software managers. It will also be useful to applications developers, researchers, and advanced students. While the techniques presented here can improve any application, they are specifically important for large projects.
Programs from this book can be accessed via anonymous ftp at: ftp aw.com under aw.computer.science in a file entitled soukup; the code is also available on disk from Addison-Wesley Publishing Company; send requests to firstname.lastname@example.org. Comments to the author can also be sent to this same address.