The design patterns book lists 23 design patterns, but that's just the beginning! Many more patterns exist, including the specification pattern, lazy initialization, object pools, and the utility class pattern.
More articles by Jeff Langr
One of the bigger challenges with using design patterns is knowing when to use one pattern over another. The abstract factory creational pattern looks similar to the builder pattern but is used to help solve a different problem.
Your production code isn't the only place you will find a use for design patterns. The factory method pattern helps you answer a question about how to organize your test classes.
Building applications for the BlackBerry involves a few interesting wrinkles. Explore some of these challenges in building a front end for a new BlackBerry unit testing framework.
What do you do when there's no effective unit testing framework for your programming environment? Why, build your own, of course! Building a simple unit testing framework for the BlackBerry provides some interesting insights into the BlackBerry programming environment.
Patterns exist for virtually all common programming challenges, even one as simple as "how to traverse a collection of objects." The iterator pattern provides a consistent solution for something that programmers do daily.
The state pattern can help simplify complex conditional logic by representing individual states as classes, each with its own simple behavior.
Objects talking to each other and no one in control? Messages going all over the place? The mediator pattern can help you control the chaos!
Many of the design patterns lead a double life—the structure of some patterns are exactly alike, but the intent differs. An interpreter is a composite whose purpose is to support interpretation of a simple grammar.
The chain of responsibility pattern allows you to emulate a real-life chain of command. In a chain of responsibility, a request moves from handler to handler until someone is able to manage and return it to the client.
A common theme in design patterns is organizing things so as to separate high-level policy from low-level underlying details. The builder pattern does just that, by allowing a single construction policy to be realized by many different implementations.
Like the abstract factory pattern, the prototype pattern helps you adhere to a clean design by moving object creation into a polymorphic hierarchy. When using the prototype pattern, you create objects by making copies of already existing instances.
The singleton pattern is one of the simplest in the catalog of design patterns. Lurking beneath its simplicity is the potential for testing trouble!
Separating interface from implementation is a fundamental object-oriented strategy, one that's also the essence of the bridge design pattern. You can use the bridge pattern to help solve the more complex problem of separating tangled hierarchies.
Object-oriented languages provide great opportunities to isolate complexity in a system. A facade buries an unwieldy interface behind a simplified one.
Not all design patterns are complex. The adapter pattern provides a simple mechanism for conforming an interface into one that's more useful for a client application.
Visitor is often viewed as a complex pattern that's often regarded as difficult and troublesome. But, the appropriate use of visitor demonstrates what's at the heart of good object-oriented design.
The Memento design pattern presents a consistent solution for storing state, allowing you to build undo and redo support in your applications with ease.
Test doubles (aka fakes or mocks) are a great tool that allow for deeper ability to test-drive solutions. The most common way to use test doubles is to pass them via constructors or setters. But there are at least a couple other solutions.
Deriving metrics in an agile software development process can be an integral part of managing and improving execution. As with any tool, metrics used poorly can actually damage a project. A set of guiding principles for agile metrics can keep your team on track.
Take advantage of Java's CountDownLatch to simplify your multithreaded applications.
The fundamentals of test-driven development can be learned in minutes. As with any discipline, TDD can take a career to master. Using these tips can help developers on this path to mastery.
For all the things that tracking tools and iterations are good for in an agile team, teams should focus on delivering completed business value via stories.
How important is testing in software development? Explore the relationship between testability and design.
Should you write tests first, or write the code first, and then write tests after? Explore the time it takes to develop the same solution using both techniques.
Some of the best patterns weren't documented in the original Design Patterns book. The Null Object is an important pattern that can help keep some sanity in your code base.
The observer pattern provides a great way of avoiding troublesome two-way dependencies in your applications.
The proxy pattern provides a protection layer for your objects by exposing a stand-in to interested clients. I'll explore one possible use for the proxy pattern in this article.
The decorator pattern gives you the flexibility to wrap special behavior around objects. Unlike inheritance, which gives you the ability to predefine specialized behavior, using the decorator pattern allows you to dynamically attach specialized behavior.
The composite design pattern allows simplification of code through the use of a recursive class relationship. Learn how the design pattern can be incrementally derived by slowly building upon pieces of the solution.
The Strategy design pattern allows your classes to switch between various algorithms. Discover how to take advantage of this pattern in order to create a simpler, more maintainable, and more easily unit tested system.
The new arraycopy method supports more than just copying the entire contents of a source array into a target. It allows for a source and target start index, as well as a length that represents the number of elements to copy.
Take advantage of a design pattern that Java itself heavily depends upon.
Even if you did not attend JavaOne this week you have probably already heard the term OpenJDK. Here is the who, what, and where behind the announcement.
Template Method is a design pattern that presents one solution for eliminating common duplication between two or more related classes. Work through an example and try it out yourself.
It's always possible to slowly refactor toward a better design. The improved version of the code demonstrates the Command Pattern, one of the more useful recognized software design patterns. In this example, your need to test proved to be in alignment with good design concepts!
Can you write unit tests against a command-line app? Should you? Here is a chance to test-drive one possible solution.
See how refactoring can become an essential part of crafting software that can be maintained over the long run at reasonable cost.
Another view on a long debated issue: comments within code.
Take a close look at the advantages and disadvantages of Pair Programming and see if it is the right approach for your team.
See how the power of the Java 5 queue implementations, including DelayQueue, as they define constructs for common queueing needs in a thread-safe manner.
Explore the key rules of Pair Programming - a way for development teams to improve the quality of the software they produce.
Discover the conceptual framework where customers, iterative and incremental delivery are key.
Here is your chance to test a web application, a web services API, a desktop UI, or something else.
Download a tool to help you set up automated acceptance testing for your team. You will also install it, start it up, and begin to learn about its editing capabilities.
BlockingQueue is one very useful building block that can help you quickly and confidently build your own multithreaded applications.
How would you like to automate some of your testing. See how that is possible.
Gain simplicity in your J2SE 1.5 source code by utilizing Foreach Loops.
Java 1.5 introduces a new class named java.util.Formatter that allows you to do string formatting similar to the
printf function in C.
Get a head start on J2SE 1.5 (codename Tiger) while it is still in beta. Learn about the new varargs language feature.