0% found this document useful (0 votes)
24 views1 page

Factory

The Factory Method pattern defines an interface for creating an object but lets subclasses decide which class to instantiate. It avoids duplication of code for object creation by defining a separate factory method that subclasses can override to specify the type of product to create. This pattern relies on inheritance as object creation is delegated to subclasses that implement the factory method.

Uploaded by

Unknown Person
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views1 page

Factory

The Factory Method pattern defines an interface for creating an object but lets subclasses decide which class to instantiate. It avoids duplication of code for object creation by defining a separate factory method that subclasses can override to specify the type of product to create. This pattern relies on inheritance as object creation is delegated to subclasses that implement the factory method.

Uploaded by

Unknown Person
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

"Define an interface for creating an object, but let subclasses decide which class to instantiate.

The
Factory method lets a class defer instantiation it uses to subclasses." (Gang Of Four)
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 concerns. The factory method design pattern
handles these problems by defining a separate method for creating the objects,
which subclasses can then override to specify the 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.[3]

You might also like