Exercise – Design patterns
There are many OOD patterns that have shared software-design solutions of specific coding problems. OOD patterns are also often used by programmers as the way to talk about different implementations.
They are traditionally grouped into four categories: creational, behavioral, structural, and concurrency patterns. Read about them and:
- Name one pattern in each category
- Name three patterns we have used already
Answer
The four patterns—one from each of the four categories—could be the following:
- Creational patterns: Factory method
- Structural patterns: Composite
- Behavioral patterns: Visitor
- Concurrency patterns: Messaging pattern
In this book, we have already used the following patterns:
- Lazy initialization: In Chapter 6, Interfaces, Classes, and Object Construction, we initialized the
SingletonClassExample OBJECT
static field, not automatically, but only when thegetInstance()
method was called - Singleton: In Chapter 6, Interfaces, Classes, and Object Construction, see the
SingletonClassExample...