[Design mode] simple factory mode, design mode factory Mode

Source: Internet
Author: User

[Design mode] simple factory mode, design mode factory Mode
Simple Factory)It is also called the Static Factory Method mode.

The simple factory mode usually defines a factory class, which canReturn different types of product instances based on different variables.

But the simple factory Model Does not belongOne of the 23 Gof design patterns. Advantages

The factory class of the simple factory model is the key to the entire model. This includes the necessaryLogical judgmentDetermine the object of the specific class to be created based on the external information.

By using the simple factory mode, you do not need to know how the object is created, as long as necessary information is passed in.

Disadvantages

The factory class integrates the creation logic of all instances,ViolationHigh Cohesion responsibility allocation principle.

As the number of product categories in the system increases, it is necessary to constantly modify the factory categories, which is not easy to maintain and expand. In additionViolating the open and closed Principle

Reference: http://www.cnblogs.com/jingmoxukong/p/4250277.html

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.