SlideShare a Scribd company logo
4
Most read
6
Most read
7
Most read
Factory Method
& Abstract Factory
Eng. Guillermo Salazar
Co-Founder Senzil S.R.L.
Senior Software Engineer September 2016
Design Pattern Series
1
Agenda
• Why Creational Patterns?
• Factory Method
– Purpose / Applies When…
– UML
– Sample in Java
• Abstract Factory
– Purpose / Applies When…
– UML
– Sample in Java
• Summary
• Q & A
2 / 15www.senzil.com
Why Creational Patterns?
Why is recommended
to Use Creational
Design Patterns?
3 / 15www.senzil.com
Why Creational Patterns?
– Abstract the instantiation process (it
sometimes could be very complicated)
– Encapsulate knowledge about
which concrete classes the system is
using.
– Flexible the what, who, how and
when the object are created.
– Be an independent the way create,
compose, and represent the objects.
TO
4 / 15www.senzil.com
Factory Method - Purpose
It defines an interface to create an
object, but it does not create the
object.
It delegates on all subclasses, which
object will be created.
This class (an interface or an abstract
class) does NOT know about any
concrete class (only the super class).
5 / 15www.senzil.com
Factory Method - Applies when…
• You have more than one class sharing
the same parent class.
• It is not possible to know, the concrete
class to create in the compile time.
• You do NOT want to have infinite
statements IF / ELSE to create
objects.
6 / 15www.senzil.com
Factory Method - UML
7 / 15www.senzil.com
Factory Method – Sample Code
Show Java code in Eclipse…
8 / 15www.senzil.com
Abstract Factory - Purpose
• It defines an interface to create
object's families, but it doesn't create
the objects.
• The objects are called family,
because all of them are related.
• This class (an interface or an abstract
class) does NOT know about any
concrete class (only the super class).
9 / 15www.senzil.com
Abstract Factory - Applies when…
• It is not possible to know, the
concrete class to create in the
compile time.
• The objects family are done to be
managed together. It must be
fulfilled, and allow us to be
consistent when we use the objects.
10 / 15www.senzil.com
Abstract Factory - UML
11 / 15www.senzil.com
Abstract Factory – Sample Code
Show Java code in Eclipse…
12 / 15www.senzil.com
Summary – Creational Design Patterns
• They are used and created to
deal with object creation
mechanisms, trying to create
objects in a manner suitable
depending on the situation.
• It allows us to have a flexible
design when we need to do a
change in our source code.
13 / 15www.senzil.com
Q&A
14 / 15www.senzil.com
Thank You For Your Attention!
If you have questions, you can contact me:
bitbucket.org/salazarguille/design_patterns
You can get the source code in the below URL:
guillermo@senzil.com
guillesalazar@gmail.com
15 / 15www.senzil.com

More Related Content

PPTX
Factory Method Pattern
PPTX
Design pattern (Abstract Factory & Singleton)
PPT
Composite pattern
PPT
Builder pattern
PPTX
Design Patterns - Abstract Factory Pattern
PPTX
Prototype design patterns
PPT
Flyweight pattern
KEY
Solid principles
Factory Method Pattern
Design pattern (Abstract Factory & Singleton)
Composite pattern
Builder pattern
Design Patterns - Abstract Factory Pattern
Prototype design patterns
Flyweight pattern
Solid principles

What's hot (20)

PDF
Angular - Chapter 4 - Data and Event Handling
PPTX
Design Pattern - Factory Method Pattern
PPTX
Proxy Design Pattern
PDF
ReactJS presentation
PPTX
Factory Design Pattern
PPT
Prototype pattern
PPT
Design Pattern For C# Part 1
PPTX
Design Pattern - Singleton Pattern
PPTX
Jetpack Compose - Android’s modern toolkit for building native UI
PPTX
The Singleton Pattern Presentation
PDF
Spring Boot
PPTX
Introduction to react_js
PDF
Factory method pattern (Virtual Constructor)
KEY
SOLID Design Principles
PDF
Introduction to SOLID Principles
ODP
Prototype_pattern
PPTX
Singleton Pattern (Sole Object with Global Access)
PPTX
Java Exception Handling and Applets
PDF
Android Networking
PPTX
Introduction to Spring Framework
Angular - Chapter 4 - Data and Event Handling
Design Pattern - Factory Method Pattern
Proxy Design Pattern
ReactJS presentation
Factory Design Pattern
Prototype pattern
Design Pattern For C# Part 1
Design Pattern - Singleton Pattern
Jetpack Compose - Android’s modern toolkit for building native UI
The Singleton Pattern Presentation
Spring Boot
Introduction to react_js
Factory method pattern (Virtual Constructor)
SOLID Design Principles
Introduction to SOLID Principles
Prototype_pattern
Singleton Pattern (Sole Object with Global Access)
Java Exception Handling and Applets
Android Networking
Introduction to Spring Framework
Ad

Similar to Design Patterns - Factory Method & Abstract Factory (20)

PPT
Unit 2-Design Patterns.ppt
PPTX
design patter related ppt and presentation
PPTX
Code Like a Ninja Session 7 - Creational Design Patterns
PPTX
Creational Design Patterns.pptx
PPTX
PDF
Factory Design Pattern
PPTX
Let us understand design pattern
PDF
Why Design Patterns Are Important In Software Engineering
PPTX
PATTERNS02 - Creational Design Patterns
PPTX
Creational Patterns
PPTX
Creational pattern
PPTX
CREATIONAL Pattern .pptx
PPTX
Gof design patterns
PPT
PPTX
Lecture-7.pptx software design and Arthitechure
PPTX
Design Patterns
PDF
03-Factory Method for design patterns.pdf
PDF
E1803023637
PPTX
Creational pattern 2
DOCX
Abstract factory
Unit 2-Design Patterns.ppt
design patter related ppt and presentation
Code Like a Ninja Session 7 - Creational Design Patterns
Creational Design Patterns.pptx
Factory Design Pattern
Let us understand design pattern
Why Design Patterns Are Important In Software Engineering
PATTERNS02 - Creational Design Patterns
Creational Patterns
Creational pattern
CREATIONAL Pattern .pptx
Gof design patterns
Lecture-7.pptx software design and Arthitechure
Design Patterns
03-Factory Method for design patterns.pdf
E1803023637
Creational pattern 2
Abstract factory
Ad

Recently uploaded (20)

PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
KodekX | Application Modernization Development
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Empathic Computing: Creating Shared Understanding
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Machine learning based COVID-19 study performance prediction
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PPTX
sap open course for s4hana steps from ECC to s4
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
Encapsulation_ Review paper, used for researhc scholars
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
KodekX | Application Modernization Development
NewMind AI Weekly Chronicles - August'25 Week I
Unlocking AI with Model Context Protocol (MCP)
Empathic Computing: Creating Shared Understanding
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Diabetes mellitus diagnosis method based random forest with bat algorithm
Network Security Unit 5.pdf for BCA BBA.
Machine learning based COVID-19 study performance prediction
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
MYSQL Presentation for SQL database connectivity
Review of recent advances in non-invasive hemoglobin estimation
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
sap open course for s4hana steps from ECC to s4
The Rise and Fall of 3GPP – Time for a Sabbatical?
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Chapter 3 Spatial Domain Image Processing.pdf
Advanced methodologies resolving dimensionality complications for autism neur...

Design Patterns - Factory Method & Abstract Factory

  • 1. Factory Method & Abstract Factory Eng. Guillermo Salazar Co-Founder Senzil S.R.L. Senior Software Engineer September 2016 Design Pattern Series 1
  • 2. Agenda • Why Creational Patterns? • Factory Method – Purpose / Applies When… – UML – Sample in Java • Abstract Factory – Purpose / Applies When… – UML – Sample in Java • Summary • Q & A 2 / 15www.senzil.com
  • 3. Why Creational Patterns? Why is recommended to Use Creational Design Patterns? 3 / 15www.senzil.com
  • 4. Why Creational Patterns? – Abstract the instantiation process (it sometimes could be very complicated) – Encapsulate knowledge about which concrete classes the system is using. – Flexible the what, who, how and when the object are created. – Be an independent the way create, compose, and represent the objects. TO 4 / 15www.senzil.com
  • 5. Factory Method - Purpose It defines an interface to create an object, but it does not create the object. It delegates on all subclasses, which object will be created. This class (an interface or an abstract class) does NOT know about any concrete class (only the super class). 5 / 15www.senzil.com
  • 6. Factory Method - Applies when… • You have more than one class sharing the same parent class. • It is not possible to know, the concrete class to create in the compile time. • You do NOT want to have infinite statements IF / ELSE to create objects. 6 / 15www.senzil.com
  • 7. Factory Method - UML 7 / 15www.senzil.com
  • 8. Factory Method – Sample Code Show Java code in Eclipse… 8 / 15www.senzil.com
  • 9. Abstract Factory - Purpose • It defines an interface to create object's families, but it doesn't create the objects. • The objects are called family, because all of them are related. • This class (an interface or an abstract class) does NOT know about any concrete class (only the super class). 9 / 15www.senzil.com
  • 10. Abstract Factory - Applies when… • It is not possible to know, the concrete class to create in the compile time. • The objects family are done to be managed together. It must be fulfilled, and allow us to be consistent when we use the objects. 10 / 15www.senzil.com
  • 11. Abstract Factory - UML 11 / 15www.senzil.com
  • 12. Abstract Factory – Sample Code Show Java code in Eclipse… 12 / 15www.senzil.com
  • 13. Summary – Creational Design Patterns • They are used and created to deal with object creation mechanisms, trying to create objects in a manner suitable depending on the situation. • It allows us to have a flexible design when we need to do a change in our source code. 13 / 15www.senzil.com
  • 15. Thank You For Your Attention! If you have questions, you can contact me: bitbucket.org/salazarguille/design_patterns You can get the source code in the below URL: guillermo@senzil.com guillesalazar@gmail.com 15 / 15www.senzil.com