Design Patterns Learning Notes

Source: Internet
Author: User

Factory method, Abstract factory

Factory method is to produce a product (new instance) of the process to the factory, need a product directly to the factory, do not have to produce their own (you may need to set a lot of properties of the new instance, so put this work to the factory), a factory can only produce a class of products;

Abstract factories are abstracted from factories, and a factory can produce multiple categories of products.


decorative mode, appearance mode, proxy mode, bridging mode, mediation mode
The decoration mode needs to pass the decorated instance to the decorator;
The appearance pattern is to unify the things that are always done together into a function, the function to invoke the specific things to do, similar to the matter to abstract a layer;
Proxy mode is the sole agent of the agent;
Bridge mode is to introduce a bridge, through the bridge to achieve a certain purpose, such as courier when we put the parcel to courier company, at the same time tell The courier company to send to where you can, and do not care about how the specific delivery, The courier company here is equivalent to bridge; (JDBC)
The mediation pattern is that the mediator mediator holds the corresponding resource (an instance of the class) when we need these resources (some methods that need to invoke the instance) by applying to the mediator (the method that invokes the mediator).

single-row mode, enjoy meta mode
Single-column mode is the same instance that each client invokes;
The enjoy meta-mode Initializes a certain number of instances in advance, where one instance can be used by only one client, and when the call is finished, the other client will be able to use the instance again, i.e. each instance can be reused. (Connection pool)

Template Method
The polymorphism implemented by inheritance.

Observer Pattern
Callbacks are implemented via interfaces.

Responsibility Chain Model
An instance of type a a1 can hold another instance of type a a2, and when a method called A1 () is invoked, A1.method () calls A2 if there is A2.method. (Interceptor)

State mode
Depending on the state (for example, the value of an attribute variable), the behavior is different (the result of calling the function or the process of executing it).

Visitor Mode
Suitable for a relatively stable data structure, but the algorithm is prone to change the system, the other is not suitable.

Interpreter Mode

Gives the interpreter expression a context context,expression the corresponding value from the context to be computed (the context is interpreted).


Design Patterns Learning Notes

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.