Content deleted Content added
m Fixed broken link to docs.microsoft.com |
|||
Line 24:
Creating 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 [[concern (computer science)|concerns]]. The factory method design pattern handles these problems by defining a separate [[method (computer science)|method]] for creating the objects, which [[subclass (computer science)|subclasses]] can then override to specify the [[Subtyping|derived type]] of product that will be created.
The factory method pattern relies on inheritance, as object creation is delegated to subclasses that implement the factory method to create objects. As per the C# example below, the factory method pattern can also rely on an Interface being implemented.<ref>{{cite book
| last1 = Freeman
| first1 = Eric
|