2 3 design patterns

xiaoxiao2021-03-06  85

Abstract Factory: Provides an interface that creates a series of associated or interdependent objects without specifying their specific classes. Adapter: Converts a class interface into another interface that customers want. Adapter mode makes it possible to work with those classes that are not compatible with interfaces. Bridge: Separate the abstraction portion with its achievement, so that they can change independently. Builder: Separate a complex object with its representation, so that the same build process can create different representations. Chain of Responsibility: Coupling between the requesting sender and the recipient, and makes multiple objects have the opportunity to handle this request. Connect these objects into a chain and deliver the request along this chain until there is an object to handle it. Command: Package a request into an object, allowing you to use different requests to parameterize the customer; queuing or logging the request log, and supports the cancel action. Composite: Combine the object into a tree structure to represent a "part-overall" hierarchy. Composite makes the customer consistency for a single object and composite object. Decorator: Dynamically add some additional responsibilities to an object. In terms of extension, Decorator is more flexible than generated subclasses. FACADE: Provides a consistent interface for a set of interfaces in the subsystem, and the FACADE mode defines a high-level interface, which makes this subsystem easier to use. Factory method: Define an interface to create an object, let the subclass decide which class instantiate. Factory Method delays a class of instantiation to their subclasses. Flyweight: Use sharing technology to effectively support a lot of fine-grained objects. Interpreter: a given language, defining a representation of its textual law, and defines an interpreter that uses this representation to explain the sentence in the language. Iterator: Provides a method sequence access to each element in a polymeric object, and does not need to expose internal representation of the object. Mediator: Use a mediation object to encapsulate a series of object interactions. The intermediaries make the objects need not be explicitly cited to each other, making them rolling, and can independently change the interaction between them. MEMENTO: When the encapsulation is not damaged, capture an internal state of an object and saves this state outside of the object. This will restore this object to the saved state in this later. Observer: Defines a one-to-many dependency between the objects so that all objects that depend on its objects are notified when the status of an object changes and automatically refreshes. Prototype: Specify the type of the object with a prototype instance and create a new object by copying this prototype. Proxy: Provides a proxy for other objects to control access to this object. Singleton: Ensure that a class has only one instance and provides a global access point access to it. State: Allows an object to change its behavior when its internal state changes. Objects seem to modify the class it belongs. Strategy: Defines a series of algorithms to encaps them one by one, and allow them to replace each other. This model makes changes in algorithms can be independent of their customers. Template Method: Defines the skeleton of the algorithm in an operation, and delays some steps into the subclass. Template Method allows subclasses to redefine certain specific steps of the algorithm without changing the structure of an algorithm. Visitor: Represents an operation of each element acting in a target structure. It allows you to define new operations for these elements without changing the class of each element.

转载请注明原文地址:https://www.9cbs.com/read-107319.html

New Post(0)