The Wayback Machine - https://web.archive.org/web/20160510120910/http://www.informit.com:80/guides/content.aspx?g=cplusplus&seqNum=146

Home > Articles > Programming > C/C++

C++ Reference Guide

Hosted by

Design Patterns

Last updated Jan 1, 2003.

Design Patterns became famous relatively recently, yet they're hardly new. Their origins can be traced back to the early days of Smalltalk, when users noticed that different and complex programming tasks consisted of smaller, recurrent design idioms serving as the building bricks of large-scale designs. They decided to formalize these recurrent idioms so that they could be reused later by other programmers, very much like standard algorithms and containers are used today.

The main difference between Design Patterns and standard libraries of algorithms is that the former are mere concepts, not actual code. This is advantageous because patterns aren't bound to a specific programming language or a platform, at least in theory.

Alas, this is also Design Patterns' main weakness: to use a Design Pattern, programmers must write it from scratch. Another problem associated with Design Patterns is that programmers who have learned a few of them start to use them excessively. For example, an application that happens to use a single data file all of a sudden wraps it in a Singleton object, even if a Singleton object isn't really necessary in this case.

That said, Design Patterns are an essential tool in every professional programmer's arsenal; ignoring them altogether would be a mistake. In this section I will introduce some of the more widely-used Design Patterns that have been implemented in C++.