Research on design pattern

Source: Internet
Author: User

1. Adapter mode

     class adapters     object adapters     default adapter mode   2. Bridge mode      decoupling abstraction from implementation, Enables both independent changes      bridging: Bridging the separated abstraction and implementation parts         How to Bridge: Bridging in the program is reflected in the abstract part of the interface object that has the implementation part         who will bridge the problem:        Who's going to be responsible for creating the abstract and implementing parts of the relationship      3. Combined mode composite        group objects into a tree dismiss to indicate "whole-part" Hierarchy  4. Enjoy meta-mode flyweight        take a share to avoid the overhead of having a large number of objects with the same content   5. Responsibility Chain mode     When a customer submits a request, from the first object, the object that receives the request in the chain either handles it personally or forwards it to the next candidate in the chain.   6. Template mode     defines an algorithm skeleton in an operation, delaying some steps into subclasses.     Basic methods: The basic method is also known as the basic operation, is the method implemented by the child class, and then called in the template method     Template method: is generally a concrete method, that is, a skeleton, the implementation of the basic method of scheduling the completion of fixed logic     Hook method: declared by the abstract class and implemented   7. Command mode: A separation coupling extracted from the interface design, improved reuse, is considered the most elegant and simple mode of the receiver of the pattern   command: The recipient can be any class, There is no special requirement for it, and this object knows how to actually perform the operation of the command, Execution is reversed from the command's implementation class. Smart commands: The ability to implement command requirements instead of receivers the object that initiates the request and the object that is actually implemented is the decoupled receivercommandinvokerclient 8. State mode    Allows an object to change its behavior when its internal state changes. The function of State mode is the behavior of separating state, and the different functions corresponding to different states can be called by maintaining state change. That is: States and behaviors are associated, and their relationships can be described as: state-determined behavior.  9. Appearance mode (facade)     provides a simple interface for a complex subsystem     provides subsystem amount independence     in a hierarchical structure, You can use the facade mode to define the ingress  10 for each layer in the system. The policy mode (strategy)     Policy mode is also called the algorithm family mode, which defines the different algorithm families and can replace each other. This pattern allows the algorithm to change independently of the customer using the algorithm.     Strategy mode belongs to the object behavior mode. There are several objects in the     policy model:        Environment objects: This class implements references to interfaces or abstract classes defined in an abstract policy         Abstract policy mode: it can be implemented by an interface or abstract class         Concrete abstract mode: It encapsulates different algorithms for implementing different functions        11. Visitor Mode (Visitor)     behaves as a visitor, is accepted by the object being accessed, and then executed by the Access object      12. Observer mode (Observer)     object behavior mode, also called publish-subscribe mode     Abstract Theme roles     Abstract viewer roles     Specific theme roles     specific observer role      Observer model benefits   &NBS P The     Observer pattern creates an abstract coupling between the observer and the Observer. What the observer role knows is a specific list of observers, each of which conforms to an abstract observer interface.         Observer mode support for broadcast communication      Observer mode         If an observer object has a lot of direct andAn indirect observer, all observers are notified to spend a lot of time         If there is a cyclic dependency between the observers, the observed will trigger a cyclic call between them, causing the system to crash       If the notice to the observer is delivered asynchronously via another thread, the system must ensure that the delivery is conducted in a self-consistent manner     13. Broker mode         Encapsulates a series of interactive objects with a mediation object     Mediator: Broker interface     Concretemediator: The specific mediator implements the object. It needs to maintain the interaction between the individual colleague objects     colleague: The colleague class definition, the parent class of all the specific colleague classes, is usually implemented into abstract classes, which are primarily responsible for constraining the types of colleague objects and implementing functions between specific colleague classes.     Concretecolleague: The specific colleague class, realizes own business, when needs to communicate with other colleague, communicates with the intermediary who holds, the intermediary is responsible for interacts with other colleague.      Generalized intermediaries         Eliminate the parent of colleague Objects         co-workers do not define the Mediator interface and implement a specific broker into a single case & nbsp       Colleague objects no longer hold intermediary objects, but are created within specific processing methods, or acquired, or passed from parameters to required colleague Objects       14. Memo Mode     & nbsp   captures the internal state of an object without compromising encapsulation, and saves the state outside that object.         The original initiator class (originator) creates a memo object that uses memos to store its internal state         responsible for human (caretaker)   Responsible for saving the memo object, unable to check or manipulate the contents of the memo         Memo Class (Memento)   Store the internal state of the original, and the generator decides as neededThe memo stores which internal states of the original generator. Prevents objects other than the original from accessing the memo. The memo has two interfaces, one is a narrow interface and the other is a wide interface. Caretaker can only see the narrow interface, it can only pass the memo to other objects. Instead, originator sees a wide interface that allows it to access the data needed to return to its previous state             15. Proxy mode       The   proxy mode, also known as the delegate mode, is a basic design technique. The need for other patterns (such as state mode, policy mode, visitor mode) is essentially a proxy mode in more special situations. And in the daily application, the proxy mode can provide very good access control.         Subject (abstract theme role) general business type definition         Realsubject (specific theme role) concrete performer of business logic   & nbsp     Proxy (agent-themed role) is responsible for the application of real role, and the real role of the completion of the process of preprocessing and rehabilitation work     General agent     mandatory agent     virtual agent      Proxy Model summary         Responsibilities clear: the real role is to achieve the actual business logic, do not care about other non-responsibility of the transaction, through the late agent to complete a transaction.         High scalability: Specific theme roles are changed at any time, as long as it implements the interface, it is the interface specification         16. Decoration Mode         Deco mode wrap real objects     17. Factory mode     Simple Factory mode         does not meet OCP principles, is to provide an interface instantiation selection     Factory method mode         to meet OCP principles     Abstract factory model        The dimensional segmentation of the simple factory model makes a more detailed specification   18. Singleton mode     system level there is a unique instance      a hungry man load      lazy load    -Requires a synchronous lock mechanism for     double check lock    --in order to solve lazy load slow performance problem, but need to use a keyword volatile    Static internal class loading    --solves the performance problem   19 by means of static internal classes. Builder mode     encapsulate complex internal creation internally, for external callers, only incoming builders and construction tools, about how the interior is built into the finished product, the caller does not need a relationship, the actual design and construction decoupling, non-interference.  20. Summary of prototype patterns     create objects compared to new, prototype mode performance     replicate directly through clone, constructors are  21 that are not executed. Iterators         Separate the responsibilities of data storage and data traversal, adding new iterator classes to the additional aggregation classes that need to be aligned.             

Design Pattern Research

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.