Design pattern shorthand

  • 2021-12-04 19:35:27
  • OfStack

Creative pattern

Static Factory Mode (Factory Pattern) Static methods return instances

The abstract factory mode (Abstract Factory Pattern) interface returns an instance

Builder mode (Builder Pattern) returns multiple instances at a time

There is only one instance of the singleton pattern (Singleton Pattern) class

Implementation of ICloneable Interface in Prototype Mode (Prototype Pattern)

Structural pattern

The adapter mode (Adapter Pattern) does not want to implement every interface

Bridge mode (Bridge Pattern) sets an instance of the bridge and calls the instance method with the bridge

Filter mode (Filter, Criteria Pattern) filters collections by condition

Combination pattern (Composite Pattern) tree structure with parent and child nodes

Decorator mode (Decorator Pattern) adds some decoration to the method

Appearance mode (Facade Pattern) Relationship between computer and CPU and memory

Enjoy meta-mode (Flyweight Pattern) is similar to threadpool management thread?

The proxy mode (Proxy Pattern) cannot modify a method, inheriting this class to extend the method

Behavioral pattern

The Responsibility Chain Mode (Chain of Responsibility Pattern) recipient contains a reference to another recipient, and if an object cannot handle the request, it passes the same request to the next recipient

Command mode (Command Pattern) is data-driven, wrapped in an object in the form of a command and passed to the calling object

The interpreter pattern (Interpreter Pattern) implements an expression interface that interprets a specific context. This pattern is used in SQL parsing, symbol processing engines, and so on

The iterator pattern (Iterator Pattern) implements the collection class, iterator

Mediator pattern (Mediator Pattern) reduces the complexity of communication between multiple objects and classes. This pattern provides a mediation class, which usually handles communication between different classes and supports loose coupling, making the code easy to maintain

Memo Mode (Memento Pattern) Backup 1 piece of data, which can be restored later

Observer mode (Observer Pattern) delegate method invocation

The state mode (State Pattern) calls different methods based on the state

Default behavior of empty object mode (Null Object Pattern) in empty state

Policy mode (Strategy Pattern) add, substract classes implement calculator interface, and one auxiliary class is used to implement calculation

The template pattern (Template Pattern) abstract class calls other virtual methods with one seal method, and the virtual methods are implemented in the subclass

Visitor mode (Visitor Pattern) accepts visitor to call its own method through accept (visitor) method


Related articles: