Chapter 12. Learning design patterns
This chapter covers
- Using worker object pattern
- Using the wormhole pattern
- Using the participant pattern
- Using the annotation-driven participant pattern
Design patterns define solutions to recurring problems. Familiarity with these patterns often leads to a quick and proven solution; no wonder several books and articles are devoted to design patterns in every major technology. Patterns also carry names like factory, visitor, and decorator to simplify the communication of design concepts. Pattern names also convey the designer’s intent and decisions succinctly and accurately without providing all the details.
This chapter presents AOP design patterns that can help you define solutions when you start applying AOP. They can also help you start thinking about problems in more abstract terms. Although this book covers problems from many domains, you’ll no doubt encounter new problems as you begin using AOP in your projects. When that happens, you’ll find that a combination of these design patterns will lead you to a solution more quickly.
In this chapter, we’ll examine four design patterns: the worker object pattern, the wormhole pattern, the participant pattern, and the annotation-driven participant pattern. We’ll use AspectJ to illustrate each pattern. Except for the wormhole pattern, you can implement them using Spring AOP as well. In the chapters that follow, we’ll use these patterns for more advanced crosscutting implementations.