0% found this document useful (0 votes)
14 views7 pages

Factory Design Patterns Guide

The document discusses different types of factories that can be used for object creation including factory methods, external factories, inner factories, and abstract factories. A factory method is a function that creates objects, a factory can take care of object creation and reside inside or outside an object, and factory hierarchies can create related objects.

Uploaded by

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

Factory Design Patterns Guide

The document discusses different types of factories that can be used for object creation including factory methods, external factories, inner factories, and abstract factories. A factory method is a function that creates objects, a factory can take care of object creation and reside inside or outside an object, and factory hierarchies can create related objects.

Uploaded by

pixoga8262
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Factories

Dmitri Nesteruk
@dnesteruk dn@[Link] [Link]
Module Overview

Motivation
Point Initialization Example
Factory Method
Factory External Class
Factory Inner Class
Abstract Factory
Motivation
 Object creation logic becomes too convoluted
 Constructor is not descriptive
- Name mandated by name of containing type
- Cannot overload with same sets of arguments with different names
- Can turn into ‘optional parameter hell’
 Object creation (non-piecewise, unlike Builder) can be outsourced to
- A separate function (Factory Method)
- That may exist in a separate class (Factory)
- You can even have a hierarchy of classes with Abstract Factory
A separate component responsible solely
Factory for the wholesale (not piecewise) creation
of objects.
Abstract A factory construct used to construct
Factory object in hierarchies.
Factory A function that helps create objects. Like a
Method constructor but more descriptive.
Module Overview

A factory method is a function that


creates objects
A factory can take care of object creation
A factory can reside inside the object or
be external
Hierarchies of factories can be used to
create related objects

You might also like