Education and Libraries
The best that an individual or an organization can do to improve the ability to produce good code (that is clean, maintainable, efficient code) is to master modern C++ programming styles and use good libraries.
The best that an individual or an organization can do for the general community is to contribute a good, well-documented library for a field in which adequate libraries don't yet exist.
In this context, I'd like to mention some books. These are books on programming style and libraries that I have had a small hand in as an editor. In several cases, I've encouraged the writing of these books because I thought their topics important. In every case, I've nagged the author to try to make the book shorter and more accessible to the reader.
Accelerated C++ [Koenig,2000] is an innovative textbook that teaches standard C++ from scratch to beginners assumed to have programmed before in some other language. It presents every feature in a context where the feature is realistically used effectively, relies on the standard library to teach effective programming styles, and doesn't introduce basic language facilities (such as pointers and arrays) until they're needed. It is also a most useful book for C++ programmers who want to move on to more modern styles of C++ programming. For example, Accelerated C++ introduces templates several chapters before pointers.
Exceptional C++ [Sutter,2000] explores the uses of exceptions in quite some depth. Similarly, Modern C++ Design [Alexandrescu,2001] assumes that a reader understands the basis of templates and generic programming, and proceeds to demonstrate several advanced and interesting techniques. These are books for people who are not satisfied with introductory-level explanations or simple descriptions of language facilities. They expand into advanced programming techniques and into technical details that wemost of the timeprefer to remain hidden inside libraries. For most C++ programmers, these books combine the intellectual thrill of discovering something new with practical techniques for building and using libraries.
Modern C++ Design serves as a bridge to the second type of book that I want to mention: the documentation of the design and facilities of interesting C++ libraries. Modern C++ Design presents Alexandrescu's "Loki" library for building generic components, many based on classical patterns.
C++ Network Programming [Schmidt,2002] describes ACE, a very large and very successful library for programming distributed systems. Its roots go back to the early 1990s, and it's in serious industrial use. Much of what people think of doing with threads, sockets, locks, etc., is already being done using ACE.
My favorite ACE story happened when a developer was explaining a large industrial system for medical applications at a conference. He emphasized his need for portability and someone asked the inevitable question, "So why didn't you use Java?" I had expected one of the usual answers (stressing performance, flexibility, or elegance), but he simply responded, "Because ACE runs on more platforms than Java," and carried on with his talk. The ACE style combines classical object-oriented programming with extensive use of templates for type safety and flexibility.
The final book that I'll mention here, The Boost Graph Library [Siek,2002] describes a new library. Its authors contributed the Matrix Template Library (MTL) to the numerical computation community and then proceeded to apply the lessons learned to the area of graph algorithms. The result, the Boost Generic Graph Library (BGGL) is a tour de force of generic programming. There is a heavy emphasis on flexibility, and the book also reflects many of the lessons learned about how to document generic libraries. It's an example of what you can achieve when you take a fresh look at an area applying the tools of Standard C++ [ISO,1998]. "Boost" is a collection of Open Source libraries designed to augment the C++ standard library [Stroustrup,2000] and a collection of people writing and documenting them [BOOST].
The main point of this article has been to encourage people to build and use good libraries by giving examples and a few simple arguments. Understanding the needs of a potential user community and matching those with design styles and programming techniques is harder than most programmers are willing to believe. Designing, implementing, and documenting a library for an interesting application domain is a worthy intellectual challenge. Getting a library into widespread use within its intended user community is another major challenge involving teaching at many levels. To succeed as users, designers, and implementers, we need to study examples of what can be done and what has been done. Good luck and have fun!