0% found this document useful (0 votes)
12 views

3 Design Patterns CPP Creational m3 Slides

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)
12 views

3 Design Patterns CPP Creational m3 Slides

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
You are on page 1/ 7

Factories

Dmitri Nesteruk
@dnesteruk dn@activemesa.com http://activemesa.com
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