Design pattern learning notes

xiaoxiao2021-03-06  51

I learned that there is a design pattern in a online classroom in Microsoft. I feel unfamiliar, I'm on the online Search. In general, a model has four basic elements

1. Pattern Name A Help Name, which uses two words to describe the problem, solutions and effects. Name a new mode adds our design vocabulary. The design pattern allows us to design at higher abstractions. Based on a pattern vocabulary, we can discuss the model between our own and colleagues and use them when writing documents. The model name can help us think, it is easy to exchange design ideas and design results with others. Finding the right model name is also one of the difficulties in our design model cataloging.

2. Problem describes when the mode should be used. It explains the presence of design problems and problems, which may describe specific design issues, such as how to use object representation algorithms. It is also possible to describe a class or object structure that causes unreflexible design. Sometimes the problem part will include a series of prerequisites that must be met.

3. Solution describes the composition of the design, the interrelationships between them and their respective responsibilities and collaborative methods. Because pattern is like a template, it can be applied to a variety of different occasions, so the solution does not describe a specific and specific design or implementation, but provides an abstract description of design problems and how to use a combination of elements with general meaning (class) Or object portfolio) to solve this problem.

4. Consequences describe the effects of the mode application and the problem of using the model. Although we describe design decisions, it is not always mentioned in the mode effect, but they are important for evaluating design selection and understanding of use models. Most software effects focus on the measurement of time and space, and they also express language and implementation issues. Because multiplexing is one of the elements of object-oriented design, the mode effects include its impact on the flexibility, expandability or portability of the system, explicitly listing these effects to understand and evaluate these patterns.

Some basic design patterns

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. A D A P T E R Mode allows you to work with those classes that are not compatible without compatibility.

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. It allows customers to consistency for the use of individual objects and composite objects.

Decorator: Dynamically add some additional responsibilities to an object. In terms of extension, it is more flexible than generated subclasses.

FACADE: Provides a consistent interface for a set of interfaces in the subsystem, and F A C A D E 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-82275.html

New Post(0)