Factory pattern

Factory pattern

:"See also Factory method pattern"

The Factory pattern is a creational design pattern used in software development to encapsulate the processes involved in the creation of objects.

The creation of an object often requires complex processes not appropriate to include within a composing object. The object's creation may lead to a significant duplication of code, may require information not accessible to the composing object, may not provide a sufficient level of abstraction, or may otherwise not be part of the composing object's concerns.

Some of the processes required in the creation of an object include determining which object to create, managing the lifetime of the object, and managing specialized build-up and tear-down concerns of the object.

Applicability

Use the Factory pattern when

  • the creation of the object precludes reuse without significantly duplicating code.
  • the creation of the object requires the access of information or resources not appropriate to contain within the composing object.
  • the lifetime management of created objects needs to be centralized to ensure consistent behavior.

Related patterns

The abstract factory pattern is similar to the factory pattern, but has the added intent of providing an interface to a factory purposed for the creation of families of related objects in order to enable variations of the factory to be used interchangeably. The abstract factory pattern is a compound pattern incorporating the use of the factory pattern and the interface pattern.

The factory method pattern is also concerned with the encapsulation of object creation details, but has the intent of providing an interface which defers the creation of objects to subclasses. The factory method pattern is also a compound pattern which incorporates the use of the Factory pattern and the interface pattern.

The builder pattern is also concerned with the encapsulation of object creation details, but has the intent of abstracting the steps involved in the construction process as opposed to encapsulating the entire creation process in one step. The factory pattern may encapsulate use of the builder pattern internally as part of the object creation process.


Wikimedia Foundation. 2010.

Игры ⚽ Поможем написать курсовую

Look at other dictionaries:

  • Factory-Pattern — Der Begriff Fabrikmethode (englisch Factory Method) bezeichnet ein Entwurfsmuster (engl. Design Pattern) aus dem Bereich der Softwareentwicklung. Das Muster beschreibt, wie ein Objekt durch Aufruf einer Methode anstatt durch direkten Aufruf eines …   Deutsch Wikipedia

  • Factory Pattern — Der Begriff Fabrikmethode (englisch Factory Method) bezeichnet ein Entwurfsmuster (engl. Design Pattern) aus dem Bereich der Softwareentwicklung. Das Muster beschreibt, wie ein Objekt durch Aufruf einer Methode anstatt durch direkten Aufruf eines …   Deutsch Wikipedia

  • Abstract factory pattern — The abstract factory pattern is a software design pattern that provides a way to encapsulate a group of individual factories that have a common theme. In normal usage, the client software creates a concrete implementation of the abstract factory… …   Wikipedia

  • Factory method pattern — Factory method in UML Facto …   Wikipedia

  • Factory object — In object oriented computer programming, a factory object is an object for creating other objects. It is an abstraction of a constructor, and can be used to implement various allocation schemes, such as the singleton pattern.A factory object… …   Wikipedia

  • Factory (disambiguation) — A factory is a large industrial building where goods are manufactured. The word can be traced back to the Latin factorium , which is literally a place of making (producing) .Factory may also refer to: * Factory (trading post), officially licensed …   Wikipedia

  • Factory Method — Der Begriff Fabrikmethode (englisch Factory Method) bezeichnet ein Entwurfsmuster (engl. Design Pattern) aus dem Bereich der Softwareentwicklung. Das Muster beschreibt, wie ein Objekt durch Aufruf einer Methode anstatt durch direkten Aufruf eines …   Deutsch Wikipedia

  • Pattern 1913 Enfield — Infobox Weapon|is ranged=yes caption=Pattern 1913 Enfield name=Rifle, Pattern 1913 type=Service rifle origin=UK era=pre WWI design date=1912 prod design date=Development and experimental/trials only serv design date=Did not enter service used… …   Wikipedia

  • Pattern 1861 Enfield Musketoon — Infobox Weapon name=Pattern 1861 Enfield Musketoon caption= Replica of a Pattern 1861 Enfield Musketoon. origin= Royal Small Arms Factory, Enfield, England type= Musket is ranged= yes is bladed= yes is explosive= is artillery= is vehicle= is UK=… …   Wikipedia

  • Pattern 1914 Enfield — Rifle, .303 Pattern 1914 Pattern 1914 Enfield Type Service rifle Place of origin …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”