Cheat Sheet
This summarizes the different patterns and their uses. It also includes the example usages of the patterns in the Java API.
We'll cover the following...
Notes
Pattern | Purpose |
---|---|
Prototype Pattern | Prototype pattern involves creating new objects by copying existing objects. The object whose copies are made is called the prototype. In Java the |
Factory Method Pattern | The factory method is defined as providing an interface for object creation but delegating the actual instantiation of objects to subclasses. For instance the method |
Abstract Factory | The abstract factory pattern defines an interface to create families of related or dependent objects without specifying their concrete classes. The abstract factory is particularly useful for frameworks and toolkits that work on different operating systems. For instance, if your library provides fancy widgets for the UI, then you may need a family of products that work on MacOS and a similar family of products that work on Windows. |
Adapter Pattern | The Adapter pattern allows two incompatible classes to interoperate that otherwise can't work with eachother. Consider the method |