Westward Java design patterns learning summary (29) --- mode summary

Disclaimer: This article is a blogger original article, shall not be reproduced without the bloggers allowed. https://blog.csdn.net/a770794164/article/details/90752497

According to the characteristics of design patterns, divided into creational patterns, structural patterns and behavioral patterns.

Create a schema

  1. Abstract factory pattern. Create a series of related or dependent objects of the interface, without specifying their concrete classes.
  2. The builder pattern. It represents the construct and its separation of a complex object, such that the same build process can create different representations.
  3. Factory Method pattern. A defined interface for creating an object, so decide which instance of a subclass of class, instance factory mode enables the delay to a class of its subclasses.
  4. Prototype mode. Specified kind prototype objects created instance, and create new objects by copying the prototype.
  5. Singleton. To ensure that a class has only one instance and provide a global access point to access it.

Structural model

  1. Adapter mode. Converting the interface of a class clients expect another interface. Adapter pattern makes those classes otherwise because of incompatible interfaces can not work together to work together.
  2. Bridge mode. The abstraction from its implementation so that they can be independently varied.
  3. Combined mode. Combining objects in a tree structure to represent "part - whole 'hierarchy, so that the user has a consistent combination patterns of single objects and combinations of objects.
  4. Decorative pattern. To an object dynamically add some additional responsibilities. Increased functionality, the decorative pattern is more flexible than a subclass.
  5. Appearance mode. Provide a consistent interface subsystem is a set of interfaces, schema defines the appearance of a high-level interface that makes the subsystem easier to use.
  6. Flyweight pattern. Use sharing to support large numbers of fine-grained objects.
  7. Proxy mode. To provide a controlled access proxy object for other objects.

Behavior

  1. Observer pattern. Definition of the dependencies between the subject an-many, when a state of the object changes, all objects that depend on it have been notified and updated automatically.
  2. Template Method pattern. Algorithm defines a skeletal operation, delaying some steps to subclasses, subclasses such that the template method may not change the structure of certain steps of an algorithm of the algorithm to redefine.
  3. Command mode. It encapsulates a request for an object, so you can parameterize clients with different requests; may request a log or record of the request queue, and support undoable operations.
  4. State mode. It allows an object to alter its behavior when its internal state changes, so that the object will appear to change its class.
  5. Chain of Responsibility pattern. A plurality of object a chance to handle the request, in order to avoid the coupling between the sender and recipient of the request. These objects Citylink chain, and pass the request along the chain until an object handles it so far.
  6. Interpreter pattern. Given a language, which defines a grammar representation and define an interpreter, the interpreter uses the representation to interpret sentences in the language.
  7. Intermediary model. Use a mediation object that encapsulates set of objects interact. Mediator keeping objects explicitly referring to each other, so that it loosely coupled, and can be changed independently before their interaction.
  8. Visitor pattern. It represents an operation of each element of an object structure effect. It makes you can not change the definition of the class under the premise of each element acting on the operation of these new elements.
  9. Strategy mode. Define a series of algorithms, they encapsulate each one, and they may be replaced with each other. This mode makes the algorithm can be varied independently of the clients that use it.
  10. Memo mode. Without violating encapsulation, capture and the internal state of an object, and save the state outside the object. So that later you can restore the object to a previously saved state.
  11. Iterator pattern. A method for providing sequential access to the various elements of a polymeric object, without exposing the interior of the object representation.

Guess you like

Origin blog.csdn.net/a770794164/article/details/90752497