Jump to content

Factory (object-oriented programming)

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by JIP (talk | contribs) at 06:49, 13 April 2005. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)

In object-oriented computer programming, a factory object is an object for creating other objects.

A factory object typically has a method for every kind of object it is capable of creating. These methods optionally accept parameters defining how the object is created, and then return the created object.

Factory objects are used in situations where getting hold of an object of a particular kind is a more complex process than simply creating a new object. The factory object might decide the created object's class (if applicable) dynamically, return it from an object pool, do complex configuration on the object, or other things.