CSC/ECE 517 Fall 2009/wiki3 15 Programming by Assertions

From Expertiza_Wiki
Revision as of 16:55, 13 November 2009 by Expertiza (talk | contribs)
Jump to navigation Jump to search

"Factory method is a type of creational pattern. Like other creational patterns, it deals with the problem of creating objects (products) without specifying the exact class of object that will be created. Be sure to emphasize how it is different from the more general Creator pattern. Also give several examples of how it can be used, and where it provides a more elegant solution than other creational patterns."

Introduction

  • What is factory method?

In object oriented language, factory method pattern is a creational design pattern which deals with the mechanism of creating objects of the classes without specifying the exact class of the object.

  • What is creational pattern?

In software engineering creational patterns are used to create objects suitable to the situation. In object oriented design object creation may lead to design problems if they are not controlled according to situations. Creational patterns deals with this mechanism. There are a list of different creational patterns available which solves problem of creating objects in different situations. The list includes factory design pattern as well. Here we'll see how factory design pattern is different from other creational design patterns and where it is mostly used.

List of creational patterns

   * Abstract factory pattern: centralize decision of what factory to instantiate
   * Factory method pattern: centralize creation of an object of a specific type choosing one of several implementations
   * Builder pattern: separate the construction of a complex object from its representation so that the same construction process can create different representations
   * Lazy initialization pattern: tactic of delaying the creation of an object, the calculation of a value, or some other expensive process until the first time it is needed
   * Object pool: avoid expensive acquisition and release of resources by recycling objects that are no longer in use
   * Prototype pattern: used when the type of objects to create is determined by a prototypical instance, which is cloned to produce new objects
   * Singleton pattern: restrict instantiation of a class to one object


Example of factory method

Known usage

Limitations

Conclusion

References