When talking about the simple factory model last time, and then as an extension of the simple factory, the main thing isAbstract FactoryAndFactory method
The general UML tool diagram provides some ready-made templates. You only need to import them. Let's take a look at the example using startUML:
Abstract Factory mode:
650) this. width = 650; "style =" border-bottom: 0px; border-left: 0px; width: 271px; height: 173px; border-top: 0px; border-right: 0px "title =" Abstract Factory "border =" 0 "alt =" Abstract Factory "width =" 268 "height =" 173 "src =" http://www.bkjia.com/uploads/allimg/131228/122203AY-0.jpg "/>
Factory method mode:
650) this. width = 650; "style =" border-bottom: 0px; border-left: 0px; width: 266px; height: 169px; border-top: 0px; border-right: 0px "title =" Factory method "border =" 0 "alt =" Factory method "width =" 252 "height =" 175 "src =" http://www.bkjia.com/uploads/allimg/131228/1222036317-1.jpg "/>
When I first came into contact with the design model, the first response was: Heaven! What is this! These people are boring! What's the purpose? What is the difference?
Haha, I have to admit that too much communication noise exists in too few words if I pass on the knowledge, and it even becomes an obstacle for the learners.
Below, I will make some changes to the above two figures, at least, first differentiateAbstract FactoryAndFactory method.
Use a realistic example:
Abstract Factory:
650) this. width = 650; "border =" 0 "alt =" "src =" http://www.bkjia.com/uploads/allimg/131228/122203A62-2.jpg "width =" 691 "height =" 350 "/>
Factory method:
650) this. width = 650; "border =" 0 "alt =" "src =" http://www.bkjia.com/uploads/allimg/131228/1222032B2-3.jpg "/>
The examples above are somewhat unreasonable, but some modifications are appropriate to attract your interest, but the truth is the same.
Explanation:
Compare two images
1. All include the simple factory Model
2. Place the factory on the left of the two images.
Abstract Factory: Abstractfactory
Factory method: Ctreaor
3. Product correspondence
Abstract Factory: one aspect of each factory can produce a type of product, suchNon-local FaIt is okay to buy a house instead of buying a car. Note that the tax has been paid for five years, which means that buying a car and buying a house are five years old and do not have to be the same)
Factory method: Each factory can implement multiple products of a certain type, suchNon-local FaTo settle a house, you must buy a house and buy a car. They just sorted out whether you have been paying taxes for five years and are still new to the home.
4. A few questions
Factory methodMedium, a little biased, but can be divided by level. For example:
Local level: Local
Local Level 2: Only Accounts
Non-local level 1: more than 5 years
Non-local level 2: just arrived
I want to express that it is best to have the same level for easy calling.
Briefly describe the application scenarios of the two
Factory methods and abstract factories are large application-level systems based on simple factories. In most cases, they are also called by client and server.
I have to interview again tomorrow .. Write the specific code examples of the two in another day, the actual examples, and the detailed scenario application.
This article is from the "scholar" blog, please be sure to keep this source http://yjplxq.blog.51cto.com/4081353/955356