Words - a prototype model
Sometimes, we want to create objects in general are very similar, but in some attribute values differ, but their initialization process is relatively complex and require a certain amount of time spent, then we can use the prototype. First of all, an initialization of an instance of a class, and then other examples of the first examples of cloning to create. And then, or cloning (clone) to deal with their different, or by the caller to deal with, depending on which is more concerned about their differences. If the caller does not care about their differences, then there should be copies of ways to deal with their differences and return to an example.
This model in <Design Pattern> is like this:
Examples used to develop a prototype to create the type of object, and through the copy of these prototypes to create a new object.
The applicability of his:
When a system should be independent of the products with his creation, composition, Oh said when. (In other words, the caller is not concerned about how to call the object is created, the internal structure is, how, and by the cloning method to deal with)
In order to avoid the creation of a parallel with the product category of factory-level class hierarchy (for we have introduced the factory method, a plant can have more than one type of factory methods to create different products, respectively, when a factory class that there is only one factory method, then this factory class and its products in a parallel interface on the level, this time in order to avoid creating too many categories of plants, leading to the complex structure of the prototype model can be used).
When a type of vision can only be a few different states of a portfolio, the establishment of a corresponding number of prototypes and clone them than the status of each with the appropriate type of hand the city to spend more convenient (this is what we talked about above initialization problem of the so-called)
.Net Object Oriented Programming Articles
- To: design patterns Singleton (the example is C #)
- Words - a prototype model
- Words: one-piece model
- To the practical application of a factory. Can be directly used by heart
- To: "simple" design pattern, then
- 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
- Words - the structure of model
- Remarks: With regard to the composition of
- Give you an example [. NET framework for development in the three examples - the user registration system]
- Jia-wen Recommended: VB.NET use object-oriented features
- Microsoft patterns and practices: model papers (Microsoft Patterns & Practices: Patterns) [strongly recommended]
- C # written norms
- Help me, I overloading (C #)
- Microsoft. NET's base class inheritance (1)
- Microsoft. NET's base class inheritance (2)
- The birth of a poker game --- (fullhouse) category on the process of design and debugging, error correction and the use of assertion (I)
- VSS data (Part III)
- VSS information (Part II, picture not uploaded)
- VSS information (and I wrote for the company, part of ICP's)
- In the team development environment using Visual Studio. NET (b)
Can't Find What You're Looking For?
Rating: Not yet rated