March 1, 2015 11:39:28 design mode

Source: Internet
Author: User

Abstract factories can create multiple product class objects, such as a root dish and a stem dish in a vegetable plant. Factory mode and abstract Factory mode and simple factory model only when the specific application, the analysis of the specific product level, and then select the appropriate design pattern.

And in the not a level, vegetable workers are not the same object of concern, in the simple factory model, workers want to grow radish or cabbage, in Factory mode, workers think of planting roots or stems, and in the abstract Factory mode, is concerned about the planting of genetic or non-genetic dishes


Summary

★ Factory mode, the important thing is the factory class, not the product class. Product classes can be in many forms, multiple layers of inheritance, or a single class are all possible. But to be clear, the factory-mode interface will only return an instance of a type, which should be noted when designing a product class, preferably with a parent class or an interface that is implemented together.

★ Using Factory mode, the returned instance must have been created by the factory and not taken from other objects.

★ Factory Mode The returned instance can not be newly created, and it is also possible to return the instance created by the factory.

Difference

Simple factory: Used to produce any product in the same grade structure. (inability to add new products)

Factory method: Used to produce fixed products in the same grade structure. (Support for adding any product)
Abstract Factory: Used to produce all products of different product families. (for adding new products, powerless; Support for adding product families)


Design mode: Agent.
A picture of a text editor.
Available in front-end UI loading


The principle of who uses, who judges.

Proxy mode application:

The opening and loading of the UI.
Open and then load, the data section and the display section are separated.
The display section is not displayed when the resource is loaded, but the data can be updated.
When the load is complete, go to refresh the display.


Observer pattern
Note that a reference causes a garbage collection mechanism and the class cannot be recycled.
When LISTITEM is using observer mode, it is best not to live new ListItem.
Push mode, Pull mode.
Update before the data is updated, or update after the data is updated. To maintain consistency.

March 1, 2015 11:39:28 design mode

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.