Tutorials to .com

Tutorials to .com » Dotnet » Oop » I Walaqi, such as with Black_Cat on "design patterns" and "factory method" "abstract factory" organize the discussion as follows, to facilitate "design mode" fans

I Walaqi, such as with Black_Cat on "design patterns" and "factory method" "abstract factory" organize the discussion as follows, to facilitate "design mode" fans

Print View , by: iSee ,Total views: 167 ,Word Count: 2200 ,Date: Tue, 21 Apr 2009 Time: 11:19 PM

Factory methods of physical products How do I know what is in the end products?
black_cat published in the 2002-12-10 11:11

Although the model is to know in order to avoid client specific physical products. However, if the modified product interface, how can the client know that this new interface?
For example, Create a Garden with the factory method to create two products Flower, Glass, abstract products are Plant, but an increase of Flower interface Color, and the absence of the Glass interface, but there is another interface EverGreenAble. That the client must be tailored to specific products or to determine how to work, but now only know that the client is the Plant type, do not know which product is, ah, how this situation do?

************************************************** ****************************** In the abstract factory to create a new new products, often with a more pronounced orientation of the features .. .
epower2002 published in the 2002-12-10 11:22

For example:
1) the establishment of an abstract Factory (Abstract Factory) category HouseFactory, statements in this category:
CreateWall ()
CreateDoor ()
CreateFloor ()
CreateCeiling ()
CreatePillar ()
2) the establishment of the corresponding products of the abstract (Abstract Product) Cluster:
Wall, Door, Floor, Ceiling, Pillar
3) the establishment of different styles for the corresponding concrete factory (Concrete Factory) category (do not forget their relations), such as:
ChinaHouseFactory: HouseFactory
GreeceHouseFactory: HouseFactory
...
4) the establishment of different styles to the specific product (Concrete Product) category (an abstract realization of the corresponding products), such as:
ChinaWall: Wall
ChinaDoor: Door
...
GreeceWall: Wall
GreeceDoor: Door
...
Specific, see "Jane, then the design model"

************************************************** ****************************** factory methods do not know whether he received specific types of products
walaqi published in the 2002-12-10 11:41 vb.net

He was just a product to operate interface.
For example: factory of createProduct1 () returns an instance of class product1.
penFactory the createproduct1 () returns an instance of class penProduct1, but they must meet a condition. All product interface to achieve

************************************************** ****************************** I know, the problem is a sub-category Product In addition to Product interfaces should also define their its own interface it
black_cat published in the 2002-12-10 12:09 VB.NET

Their own interface on the basis of specific products to determine what is the. Well, if the products to access interfaces on their own need to know what products.
I just asked about the csdn, it is said that the client can determine what the parameters of the introduction of Class (using product is Flower judge), I do not know what to judge? Lane said if tij "style back" "back under the form," but I was not able to get a thorough understanding, please advise.

************************************************** ****************************** Yes, of course.
walaqi published in the 2002-12-11 09:31 VB.NET

Can go to a class of multiple interfaces. However, other interface is used in your factory scene mode is neglected. That is another thing.
In addition, a class of multiple interfaces when the need is important to note, not to a similar type of additional responsibilities rather ambiguous.

************************************************** ****************************** be ignored? In that case is not suitable for a factory pattern?
black_cat published in the 2002-12-11 09:49

In addition, "not to a similar type of additional responsibilities rather ambiguous." What does it mean ah? I did not pass the language exam: (

************************************************** ****************************** attention to the premise: in the factory scene mode.
walaqi published in the 2002-12-11 14:17

The so-called factory scene mode is used when a customerproducts factory method and examples, this time he is concerned only about the product whether or not the product examples interface, not concerned about the example of the realization of products of other interfaces.
The responsibility of the so-called fuzzy, that is thin, you are an example of the establishment of a cat, a bird so that it interfaces to achieve, then the type name for example: the cat, the birds provided by the interface function is ambiguous.

************************************************** ****************************** That is to say in my question does not apply to the factory pattern.
black_cat published in the 2002-12-11 14:22

Whether or not the factory model and other models will be combined with the role of the application?

************************************************** ****************************** model is a combination of regular.
walaqi published in the 2002-12-11 14:25

What is your question?

************************************************** ****************************** with in the main, the paste it again
black_cat published in the 2002-12-11 14:34

For example, Create a Garden with the factory method to create two products Flower, Glass, abstract products are Plant, but an increase of Flower interface Color, and the absence of the Glass interface, but there is another interface EverGreenAble. That the client must be tailored to specific products or to determine how to work, but now only know that the client is the Plant type, do not know which product is, ah, how this situation do?
-----------------
I already know how to solve the (use of plant is Flower), but I feel as if divorced from the original intention of the factory method, and because of this the client must be aware of the exact products. Do not know whether this is beyond the scope of the factory method. If the mode of action must be to consider what models may be used to address them?

************************************************** ****************************** ho ho, do you approach the application of the plant did not understand
walaqi published in the 2002-12-11 14:37

First of all, the factory method to create a series of functions can only be used for similar products. Your flower and glass was totally irrelevant. This is not in a series.

************************************************** ****************************** It depends on the particle size analysis
black_cat published in the 2002-12-11 14:40

I started from the point of view of plant analysis. However, in the design process also found a need to refine grain size (which is not identified in the demand or need to add a new function is normal circumstances), from the perspective of reuse may have spent most of the code above , but the interface is the need to re-definition of how to handle it?

************************************************** ****************************** interface is a need to redefine the problem of trouble.
walaqi published in the 2002-12-11 14:56

Interface is the role of program structure in order to ensure stability. Be modified if the interface is undoubtedly a very bad impact caused by the procedure.
But to see the look of your face as if still in the analysis phase? Then you can modify your interface.
If the code is already in phase. Interface can be modified in two ways:
1, the definition of new interface
2, to amend the old interface, and then recompile the one hand, all the realization of the interface type checking error will appear, one by one to amend, to ensure that all of the interface has been modified. Re-compile, all references to the type of the method will also be the type to check for errors. In changes just fine.
In addition, the plant can accept the one to determine the need to return to the product line.

************************************************** ****************************** shared a product of a series of interfaces. It seems like you said there are two products that interface
walaqi published in the 2002-12-11 14:40 VB.NET

In addition, carefully read the book on the factory design pattern of the shortcomings of a model. There are notes.

************************************************** ****************************** What book did not say ah.
black_cat published in the 2002-12-11 14:46

Only in order to create a product that must be created on the plant, even if the plant in addition to the production of the products there is no use.
On the abstract factory is only saying that if you want to add product features must be re-defined on all of our products interface.

************************************************** ****************************** interface is a need to redefine the problem of trouble.
walaqi published in the 2002-12-11 14:56

Interface is the role of program structure in order to ensure stability. Be modified if the interface is undoubtedly a very bad impact caused by the procedure.
But to see the look of your face as if still in the analysis phase? Then you can modify your interface.
If the code is already in phase. Interface can be modified in two ways:
1, the definition of new interface
2, to amend the old interface, and then recompile the one hand, all the realization of the interface type checking error will appear, one by one to amend, to ensure that all of the interface has been modified. Re-compile, all references to the type of the method will also be the type to check for errors. In changes just fine.
In addition, the plant can accept the one to determine the need to return to the product line.

************************************************** ******************************
I think the most terrible problem is not demand for analysis to take into account, but will be known when the code is not complete.
black_cat published in the 2002-12-11 15:07 VB.NET

In addition, procedures on how to write as much as possible to stay for good after the upgrade interface, this procedure may need to in order to achieve the functions of the future to make a clearer analysis of ver1.0 is the time to write, taking into account ver2.0 After the use of demand. It is also difficult. Chiloscylliumthat?

************************************************** ******************************
Any person who is impossible to foresee the future
walaqi published in the 2002-12-11 20:47

Even an experienced designer resourceful and can not predict the future, for future needs that may arise well-defined interface.
Design pattern is to meet the needs of the birth, but the design is only part of the solution to this problem. To learn the ultimate goal of design patterns, is not designed to learn about ways to model, but rather learn from his expansion of the structure in order to make the design process and methods. For example, the factory model, the operation will be postponed until some of its sub-class, then gave way to the future expansion of these leaves a channel: subclass generated through inheritance to extend the logic. But when you need to use products with a large difference can not be attributed to the same interface, the factory methods no longer apply.
Another solution to the demand for change and expansion is to complete the application on the scene as much as possible to extract (that is, your own company is expected now and in the future may have to deal with a variety of scenes), the definition of a more perfect and a relatively stable structure. It has been in continuous use iteration and provide a certain number of ways to expand. However, limiting the structure to a large extent the flexibility of the proceedings, all the demand analysis must be consistent with the idea of the requirements of the structure.
Therefore, there is no way to once and for all. If we are to solve the expansion of the topic, I think the best method is: the idea of using design Patterns to build a sound structure, and then use this framework to the reconstruction carried out carefully. While the vast majority of issues can be resolved.

************************************************** ******************************
Reasonable, perhaps, is an experienced systems analyst with the common distinction between coder.
black_cat published in the 2002-12-12 13:40

Programmers in general always want to get the project started to how to achieve this project. Can start from the perspective of reusable think very few people, and to analyze the sound very little. No wonder, the demand is always changing, very few to have the procedure can automatically adapt to the needs of all. However, if the comparison of thoughtful consideration, then it is very convenient after the upgrade. Thank you, owner of the show:)


.Net Object Oriented Programming Articles


Can't Find What You're Looking For?


Rating: Not yet rated

Comments

No comments posted.