Design Patterns (Computers)

Division type schema name describe Mentioned in Design Patterns

Mentioned in Code Encyclopedia

Creational patterns
abstract factory pattern A unified creation interface is provided for a product family. When a certain series of this product family is needed, the corresponding series can be selected from the abstract factory to create a concrete factory class. yes yes
factory method pattern Define an interface for creating objects, but let subclasses decide which class to initialize. Factory methods delegate initialization of a class to subclasses. yes yes
generator pattern Separates the construction of a complex object from its representation so that the same construction process can create different representations. yes no
lazy initial mode Operations that require more resources, such as postponing object creation, data calculation, etc., are only executed when accessing for the first time. no no
object pool pattern Avoid expensive acquisition and release of resources by recycling objects. no no
prototype pattern Use the prototype instance to specify the type of object to be created, and create new objects by copying these prototypes. yes no
singleton pattern Make sure there is only one instance of a class and provide global access to that instance. yes yes
multiple instance pattern Ensures that a class has only named instances and provides global access to those instances. no no
Resource acquisition is initialized Ensure resources are properly released by binding to the appropriate object's lifecycle. no no
structural pattern
adapter pattern Transforms the interface of a class into another interface representation that clients expect. The adapter pattern can eliminate class compatibility problems caused by interface mismatches. yes yes
bridge mode Decouples an abstraction from its implementation so that the two can vary independently. yes yes
combination mode Multiple objects are formed into a tree structure to represent the part and the whole, so that the user can treat a single object and a combination of objects in the same way. yes yes
grooming mode Dynamically add more functionality to an object. The decoration pattern is another way to extend functionality besides class inheritance. yes yes
appearance mode To provide a consistent interface for a set of interfaces in a subsystem, the facade pattern defines a high-level interface that makes the subsystem easier to use. yes yes
Enjoy Yuan Shared to effectively support a large number of small-grained objects. yes no
acting Provides a proxy for other objects to control access to this object. yes no
behavioral model
blackboard Generalized observers exchange information system-wide, allowing multiple readers and writers. no no
chain of responsibility To decouple the sender and receiver of a request so that multiple objects have a chance to process the request. Link these objects into a chain, and pass the request along the chain until an object handles it. yes no
Order Encapsulates a request as an object, allowing you to parameterize clients with different requests; queue or log requests, and support cancelable operations. yes no
interpreter Given a language, define a representation of its grammar, and define an interpreter that uses this representation to interpret sentences in the language. yes no
iterator Provides a way to sequentially access the elements of an aggregate object without exposing the object's internal representation. yes yes
intermediary Wraps the way a set of objects interact so that the objects don't have to explicitly interact with each other, allowing them to be loosely coupled. When the role between some objects changes, it will not immediately affect the role between some other objects, ensuring that these roles can be changed independently of each other. yes no
memorandum A memento object is an object that stores a snapshot of the internal state of another object. The purpose of the memo mode is to capture the state of an object, externalize it, and store it without breaking the encapsulation, so that the object can be restored to the stored state at an appropriate time in the future. yes no
empty object Avoid null references by providing a default object. no yes
Observer pattern Define a one-to-many relationship between objects, whereby when one object changes state, all other related objects are notified and refreshed automatically. yes yes
Specification Rebindable business logic expressed in boolean form. no no
state Let an object change its behavior when its internal state changes. The State pattern requires creating a subclass of the State class for each possible state that the system can obtain. When the state of the system changes, the system changes the selected subclass. yes no
Strategy Define a family of algorithms, package them up, and make them interactive. The Strategy pattern enables the algorithm to change independently when used by the user. yes yes
template method The template method pattern prepares an abstract class, implements part of the logic in the form of concrete methods and concrete subclasses, and then declares some abstract methods to force the subclass to implement the remaining logic. Different subclasses can implement these abstract methods in different ways and thus have different implementations of the remaining logic. Build a top-level logical framework first, and leave the details of the logic to specific subclasses to implement. yes yes
visitor Encapsulates operations performed on elements of some data structure. Once these operations need to be modified, the data structure receiving this operation can remain unchanged. The visitor pattern is suitable for systems where the data structure is relatively undefined. It decouples the coupling between the data structure and the operations acting on the structure, so that the operation set can evolve relatively freely. yes no
concurrent mode active object It mainly decomposes the content of the method into the execution body and the request. When the concurrency processing is introduced, it can be achieved through asynchronous processing.

For example: when the method receives a request, the caller does not need to wait for the request to complete (that is, asynchronous), and then it will be set to active or busy, and the subsequent request will enter the scheduler. When the request is completed, it will be transparent Notify the noitfy caller through other threads.

no no
hinder Avoid being executed when some state is not satisfied, so it is also called (Anti-pattern) because it is a bit fool-proof. For example, if you want to read a ZIP file, when the method is executed, you call other methods and find it. If the file has not been opened, an exception will occur at this time, which can be avoided if there is balking before. no no
double check locking no no
guard no no
leader/follower no no
Monitor Object Mode no no
read-write lock no no
scheduling no no
thread pool mode no no
thread specific storage no no
reactor no no

Quote: https://zh.wikipedia.org/wiki/%E8%AE%BE%E8%AE%A1%E6%A8%A1%E5%BC%8F_(%E8%AE%A1%E7%AE% 97%E6%9C%BA) 

Guess you like

Origin blog.csdn.net/qq_15371293/article/details/127982016