CSC/ECE 517 Fall 2009/wiki3 15 Programming by Assertions: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 13: Line 13:
==List of creational patterns==
==List of creational patterns==


* Factory method pattern: centralize creation of an object of a specific type choosing one of several implementations
* '''Factory method pattern:''' centralize creation of an object of a specific type choosing one of several implementations
* Abstract factory pattern: centralize decision of what factory to instantiate
* '''Abstract factory pattern:''' centralize decision of what factory to instantiate
* '''Prototype pattern:''' Prototype means making clones. This pattern is used when the type of objects to create is determined by a prototypical instance, which is cloned to produce new objects. The cost of creating new objects is resource intensive job. This pattern gives solution in this scenario where object cloning saves this cost in terms of resources. This pattern is used to avoid building a class hierarchy of factories that parallels the class hierarchy of products.
* '''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


* Builder pattern: separate the construction of a complex object from its representation so that the same construction process can create different representations
* '''Singleton pattern:''' restrict instantiation of a class to one object
* 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





Revision as of 17:15, 13 November 2009

"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

  • Factory method pattern: centralize creation of an object of a specific type choosing one of several implementations
  • Abstract factory pattern: centralize decision of what factory to instantiate
  • Prototype pattern: Prototype means making clones. This pattern is used when the type of objects to create is determined by a prototypical instance, which is cloned to produce new objects. The cost of creating new objects is resource intensive job. This pattern gives solution in this scenario where object cloning saves this cost in terms of resources. This pattern is used to avoid building a class hierarchy of factories that parallels the class hierarchy of products.
  • 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
  • Singleton pattern: restrict instantiation of a class to one object


Example of factory method

Known usage

Limitations

Conclusion

References