First, the creation mode
1. Abstract Factory Pattern: Provides an interface for creating a family of related or dependent objects without specifying a specific class.
2. Builder pattern: Use the builder pattern to encapsulate a product's construction process and allow for the steps to be constructed. Separating the construction of a complex object from its representation allows the same build process to create different representations.
3. Factory mode (factory method pattern): Defines an interface for creating objects, but subclasses decide which class to instantiate. The factory method defers the instantiation of the class to the subclass.
4. Prototype mode (prototype pattern): Use prototype mode when creating an instance of a given class is expensive or complex.
5. Singleton mode (Singleton pattern): Ensures that a class has only one instance and provides a global access point.
6. Multiple patterns (multition pattern): combine two or more patterns in a solution to solve general or recurring problems.
Second, structural type mode
1, Adapter mode (Adapter pattern): Converts the interface of a class into another interface that the customer expects. The adapter makes it possible to work with classes that are incompatible with the original interface. The object adapter uses a combination of multiple inheritance for the class adapter.
2, Bridging mode (bridge pattern): Use bridging mode to change the implementation and abstraction independently by placing them in two different class hierarchies.
3, Combined mode (composite pattern): Allows you to combine objects into a tree structure to represent a "whole/part" hierarchy. The combination enables the customer to handle individual objects and combinations of objects in a consistent manner.
4, Decorator mode (decorator pattern): Dynamically attaches responsibility to objects, and to extend functionality, decorators provide a more resilient alternative than inheritance.
5, Appearance mode (facade pattern): Provides a unified interface for accessing a group of interfaces in a subsystem. The appearance defines a high-level interface that makes the subsystem easier to use.
6, Hengyuan mode (Flyweight pattern): If you want an instance of a class to be used to provide many "virtual instances," Use the fly volume pattern.
7, Proxy pattern: provides an alias or placeholder for another object to control access to the object.
Three, behavioral mode
1, responsibility chain mode (Chain of responsibility Pattern): Through the chain of responsibility model, you can create an object chain for a request. Each object sequentially examines the request and processes it, or passes it to the next object in the chain.
2, Command pattern: The request is closed to an object so that different requests, queues, or logs are used to parameterize other objects. The command mode also supports revocable operations.
3, Interpreter mode (interpreter pattern): Use the Interpreter mode to create an interpreter for the language.
4, iterator pattern (iterator pattern): Provides a way to sequentially access individual elements in an aggregated object without exposing their internal representations.
5, Mediator mode (mediator pattern): Use the mediator pattern to centralize complex communication and control between related objects.
6, Memo mode (Memento pattern): When you need to return an object to its previous state (for example, your user requests "undo"), you use Memo mode.
7, observer Mode (Observer pattern): Defines a one-to-many dependency between objects, so that when an object changes state, objects that depend on it are notified and updated automatically.
8, State pattern: Allows an object to change its behavior when the internal state changes, and the object looks as if it had changed its class.
9, Policy mode (strategy pattern): Defines the algorithm family, respectively closed up, so that they can be replaced with each other, this pattern allows the algorithm to change independently of the client using the algorithm.
10, Template Method pattern: Defines the skeleton of an algorithm in one method, and delays some steps into subclasses. The template method allows subclasses to redefine some of the steps in the algorithm without altering the algorithm structure.
11, Visitor mode (visitor pattern): Use the visitor pattern when you want to add new capabilities to a combination of objects, and if the encapsulation is not important.
--------------------------------------------------------------------------------------------- -----
Seven design principles:
1. Single RESPONSIBILITY PRINCIPLE: one class is responsible for one responsibility.
2, the Richter replacement principle "LISKOV SUBSTITUTION PRINCIPLE": Inheritance and derivation of the rules.
3, the dependency inversion principle "dependence inversion PRINCIPLE": high-level modules should not rely on the lower layer module, both should rely on its abstraction; abstraction should not depend on detail; detail should be dependent on abstraction. That is, for interface programming, do not program for implementation.
4, the interface isolation principle "INTERFACE segregation PRINCIPLE": Establish a single interface, do not set up a huge bloated interface, as far as possible to refine the interface, the interface of the method as little as possible.
5. Dimitri law "low of DEMETER": Cohesion Poly.
6. Open Close PRINCIPLE: A software entity such as classes, modules, and functions should be open to extensions and closed for modification.
7, combination/aggregation multiplexing principle "composition/aggregation reuse Principle (CARP)": Try to use combination and aggregation less use of inherited relationships to achieve the principle of reuse.
24 Design Patterns and 7 principles in Java (RPM)