design patterns - Purpose of factory objects/benefit over using same instance to return type -


Unlike using an example of the same object to return that object, what is the benefit of a stable factory class? For example, for example, with N 2 CMS, take a look at this code:

News Page News = Factory. (Item IDID);

// Variables can set news related to news news.

Factory. Save (news);

The factory is stable and I know what are the objects of the factory, but I do not

thanks

a constant See the benefits of the factory Instead of using a manufacturer, there is some advantage of a stable factory:

  • A manufacturer new is usually called every time. When creating a new object is necessary. However, there is not a stable factory, so you can reuse the invariant items and can cache the frequently used values, which can lead to better performance.

  • The names of stable factories are; Constructors, mostly OOP languages, should generally have the same name as the class and can only be different in their type and number of arguments. But stable factories can also have different names, as well as the number of any kind and arguments.

  • Static factories know only a piece of the object in a specific existing object, such as its identifier or they can create a completely new object if it does not exist. Again, it is difficult to do that with the console, depending on the language you are using.

  • With stationary factories, you can control that objects are present at any time - not too much with new .

  • Stable factories can return objects of any subtype, but by creating a single object the object will only create a specific type of objects using a stable factory in this way. The interface creates a good separation between the interface and the implementation.


Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -