Scope |
|
Purpose |
||
Creational |
Structural |
Behavioral |
||
Class |
Factory Method |
Adapter |
Interpreter |
|
Object |
· Abstract Factory · Builder · Prototype · Singleton |
· Adapter · Bridge · Composite · Decorator · Façade · Flyweight · Proxy |
· Chain of Responsibility · Command · Iterator · Mediator · Observer · State · Strategy · Visitor |
Public class PrintSpooler {
Private static PrintSpooler spooler;
Private PrintSpooler() {
}
Public static synchronized printSpooler get Spooler {
if (spooler == null)
spooler = new PrintSpooler();
return spooler;
}
}
Provides a simple decision-making class that returns one of several possible subclasses of an abstract base class, depending on the data that are provided
It’s used in Mathematical computations
Abstract Factory Pattern: Provides an Interface to create and return one of several families of related objects.
Builder Pattern: separates the construction of a complex object from its representation so that several different representations can be created, depending on the needs of the program.
Example: Address Book containing the group addresses and personal addresses
Prototype Pattern: starts with an instantiated class, which it copies or clones to make a new instance. These instances can then be further tailored using their public methods.
Adapter Pattern: can be used to make one class interface match another for easier programming.
Composite Pattern: Creates an object (a composition of objects), each of which may be a simple or a composite object.
Proxy Pattern: creates a simple object that takes the place of a more complex object which may be invoked later, such as when the program runs in a networked environment.
Flyweight Pattern: for sharing objects, where each instance does not contain its own state, but stores it externally. This approach allows efficient sharing of objects to save space when there are many instances, but only a few different types
Façade Pattern: used to make a single class represent an entire subsystem.
Bridge pattern: separates an object interface from its implementation.
Decorator pattern: lets you add responsibilities to objects dynamically.
Chain of Responsibility pattern: allows decoupling between objects by passing a request from one object to the next in a chain until the request is recognized.
Command pattern: utilizes simple objects to represent the execution of software commands and allows you to support logging and undoable operations.
Interpreter pattern: provides a definition of how to include language elements in a program.
Iterator Pattern: formalizes the way we move through a list of data within a class.
Mediator Pattern: defines how communication between objects can be simplified by using a separate object to keep all objects from having to know about each other.
Observer pattern: defines how multiple objects can be notified of a change.
State pattern: allows an object to modify its behavior when its internal state changes.
Strategy Pattern: encapsulates an algorithm inside of a class.
Template Method pattern: provides an abstract definition of an algorithm.
Visitor pattern: adds polymorphic functions to a class noninvasively.