What Are Design Patterns?

Design patterns are guidelines for identifying and solving common design problems in object-oriented programming. Unlike frameworks or class libraries, design patterns are abstract, providing recommendations on how to solve specific kinds of programming problems without providing fully fleshed-out code to implement those recommendations. They distill years of software programming experience into a set of recipes for object-oriented application architecture.

Design patterns were popularized and formalized in the early 90s by the publication of Design Patterns: Elements of Reusable Object Oriented Software,1 but the ideas predate the book. Many of the core design patterns, like Iterator and Singleton, are widely used and familiar to most Java and C++ programmers. Other patterns, like Builder, are less frequently used but are highly useful in the appropriate situation.

Why Use Design Patterns?

Design patterns are useful for two reasons. The obvious reason is that they help to solve common software design problems based on the collected wisdom of many programmers. This makes them invaluable as an educational tool and as a programming resource.

1Design Patterns: Elements of Reusable Object-Oriented Software by Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides. Addison-Wesley, 1995.

The second — and perhaps more important — reason is that design patterns provide a concise vocabulary for discussing design problems and their solutions. This vocabulary ...

Get Programming Interviews Exposed: Secrets to Landing Your Next Job, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.