SlideShare a Scribd company logo
4
Most read
6
Most read
12
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
Ad

Recommended

Design pattern (Abstract Factory & Singleton)
Design pattern (Abstract Factory & Singleton)
paramisoft
 
Design Patterns - Abstract Factory Pattern
Design Patterns - Abstract Factory Pattern
Mudasir Qazi
 
Factory Design Pattern
Factory Design Pattern
Jyaasa Technologies
 
Prototype pattern
Prototype pattern
Shakil Ahmed
 
Design Pattern - Factory Method Pattern
Design Pattern - Factory Method Pattern
Mudasir Qazi
 
Factory Method Pattern
Factory Method Pattern
Anjan Kumar Bollam
 
Web adi webcast_v3
Web adi webcast_v3
Bala Nagella
 
SOLID Principles and The Clean Architecture
SOLID Principles and The Clean Architecture
Mohamed Galal
 
Software Design Patterns
Software Design Patterns
Satheesh Sukumaran
 
Dependency injection presentation
Dependency injection presentation
Ahasanul Kalam Akib
 
Abstract Factory Pattern
Abstract Factory Pattern
guestcb0002
 
Clean architecture
Clean architecture
.NET Crowd
 
Java Design Patterns Tutorial | Edureka
Java Design Patterns Tutorial | Edureka
Edureka!
 
Composite pattern
Composite pattern
Shakil Ahmed
 
Ajax.ppt
Ajax.ppt
MAGNA COLLEGE OF ENGINEERING
 
Design Pattern For C# Part 1
Design Pattern For C# Part 1
Shahzad
 
Abstract Factory Design Pattern
Abstract Factory Design Pattern
Bharat Khatri
 
Prototype Design Pattern
Prototype Design Pattern
melbournepatterns
 
Prototype design patterns
Prototype design patterns
Thaichor Seng
 
Creational pattern
Creational pattern
Himanshu
 
Introduction to mvc architecture
Introduction to mvc architecture
ravindraquicsolv
 
Mvc architecture
Mvc architecture
Surbhi Panhalkar
 
Introducing Clean Architecture
Introducing Clean Architecture
Roc Boronat
 
PATTERNS02 - Creational Design Patterns
PATTERNS02 - Creational Design Patterns
Michael Heron
 
Bridge Design Pattern
Bridge Design Pattern
Shahriar Hyder
 
MVx patterns in iOS (MVC, MVP, MVVM)
MVx patterns in iOS (MVC, MVP, MVVM)
Yaroslav Voloshyn
 
Bridge Design Pattern
Bridge Design Pattern
sahilrk911
 
Spring Framework
Spring Framework
nomykk
 
Unit 2-Design Patterns.ppt
Unit 2-Design Patterns.ppt
MsRAMYACSE
 
design patter related ppt and presentation
design patter related ppt and presentation
Indu32
 

More Related Content

What's hot (20)

Software Design Patterns
Software Design Patterns
Satheesh Sukumaran
 
Dependency injection presentation
Dependency injection presentation
Ahasanul Kalam Akib
 
Abstract Factory Pattern
Abstract Factory Pattern
guestcb0002
 
Clean architecture
Clean architecture
.NET Crowd
 
Java Design Patterns Tutorial | Edureka
Java Design Patterns Tutorial | Edureka
Edureka!
 
Composite pattern
Composite pattern
Shakil Ahmed
 
Ajax.ppt
Ajax.ppt
MAGNA COLLEGE OF ENGINEERING
 
Design Pattern For C# Part 1
Design Pattern For C# Part 1
Shahzad
 
Abstract Factory Design Pattern
Abstract Factory Design Pattern
Bharat Khatri
 
Prototype Design Pattern
Prototype Design Pattern
melbournepatterns
 
Prototype design patterns
Prototype design patterns
Thaichor Seng
 
Creational pattern
Creational pattern
Himanshu
 
Introduction to mvc architecture
Introduction to mvc architecture
ravindraquicsolv
 
Mvc architecture
Mvc architecture
Surbhi Panhalkar
 
Introducing Clean Architecture
Introducing Clean Architecture
Roc Boronat
 
PATTERNS02 - Creational Design Patterns
PATTERNS02 - Creational Design Patterns
Michael Heron
 
Bridge Design Pattern
Bridge Design Pattern
Shahriar Hyder
 
MVx patterns in iOS (MVC, MVP, MVVM)
MVx patterns in iOS (MVC, MVP, MVVM)
Yaroslav Voloshyn
 
Bridge Design Pattern
Bridge Design Pattern
sahilrk911
 
Spring Framework
Spring Framework
nomykk
 
Dependency injection presentation
Dependency injection presentation
Ahasanul Kalam Akib
 
Abstract Factory Pattern
Abstract Factory Pattern
guestcb0002
 
Clean architecture
Clean architecture
.NET Crowd
 
Java Design Patterns Tutorial | Edureka
Java Design Patterns Tutorial | Edureka
Edureka!
 
Design Pattern For C# Part 1
Design Pattern For C# Part 1
Shahzad
 
Abstract Factory Design Pattern
Abstract Factory Design Pattern
Bharat Khatri
 
Prototype design patterns
Prototype design patterns
Thaichor Seng
 
Creational pattern
Creational pattern
Himanshu
 
Introduction to mvc architecture
Introduction to mvc architecture
ravindraquicsolv
 
Introducing Clean Architecture
Introducing Clean Architecture
Roc Boronat
 
PATTERNS02 - Creational Design Patterns
PATTERNS02 - Creational Design Patterns
Michael Heron
 
MVx patterns in iOS (MVC, MVP, MVVM)
MVx patterns in iOS (MVC, MVP, MVVM)
Yaroslav Voloshyn
 
Bridge Design Pattern
Bridge Design Pattern
sahilrk911
 
Spring Framework
Spring Framework
nomykk
 

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

Unit 2-Design Patterns.ppt
Unit 2-Design Patterns.ppt
MsRAMYACSE
 
design patter related ppt and presentation
design patter related ppt and presentation
Indu32
 
Code Like a Ninja Session 7 - Creational Design Patterns
Code Like a Ninja Session 7 - Creational Design Patterns
Deon Meyer
 
Creational Design Patterns.pptx
Creational Design Patterns.pptx
Sachin Patidar
 
Sda 8
Sda 8
AmberMughal5
 
Let us understand design pattern
Let us understand design pattern
Mindfire Solutions
 
Why Design Patterns Are Important In Software Engineering
Why Design Patterns Are Important In Software Engineering
Protelo, Inc.
 
Creational Patterns
Creational Patterns
Asma CHERIF
 
CREATIONAL Pattern .pptx
CREATIONAL Pattern .pptx
Roland Ivan Palasigue II
 
Gof design patterns
Gof design patterns
Srikanth R Vaka
 
Design patterns
Design patterns
◄ vaquar khan ► ★✔
 
Lecture-7.pptx software design and Arthitechure
Lecture-7.pptx software design and Arthitechure
MuhammadAbubakar114879
 
Design Patterns
Design Patterns
Sergii Stets
 
03-Factory Method for design patterns.pdf
03-Factory Method for design patterns.pdf
ssusera587d2
 
E1803023637
E1803023637
IOSR Journals
 
Creational pattern 2
Creational pattern 2
Naga Muruga
 
Abstract factory
Abstract factory
Muthukumar P
 
Weekly Meeting: Basic Design Pattern
Weekly Meeting: Basic Design Pattern
Nguyen Trung Kien
 
Software Architecture and Design Patterns Notes.pptx
Software Architecture and Design Patterns Notes.pptx
VivekanandaGN2
 
OOPSDesign PPT ( introduction to opps and design (
OOPSDesign PPT ( introduction to opps and design (
bhfcvh531
 
Unit 2-Design Patterns.ppt
Unit 2-Design Patterns.ppt
MsRAMYACSE
 
design patter related ppt and presentation
design patter related ppt and presentation
Indu32
 
Code Like a Ninja Session 7 - Creational Design Patterns
Code Like a Ninja Session 7 - Creational Design Patterns
Deon Meyer
 
Creational Design Patterns.pptx
Creational Design Patterns.pptx
Sachin Patidar
 
Let us understand design pattern
Let us understand design pattern
Mindfire Solutions
 
Why Design Patterns Are Important In Software Engineering
Why Design Patterns Are Important In Software Engineering
Protelo, Inc.
 
Creational Patterns
Creational Patterns
Asma CHERIF
 
Lecture-7.pptx software design and Arthitechure
Lecture-7.pptx software design and Arthitechure
MuhammadAbubakar114879
 
03-Factory Method for design patterns.pdf
03-Factory Method for design patterns.pdf
ssusera587d2
 
Creational pattern 2
Creational pattern 2
Naga Muruga
 
Weekly Meeting: Basic Design Pattern
Weekly Meeting: Basic Design Pattern
Nguyen Trung Kien
 
Software Architecture and Design Patterns Notes.pptx
Software Architecture and Design Patterns Notes.pptx
VivekanandaGN2
 
OOPSDesign PPT ( introduction to opps and design (
OOPSDesign PPT ( introduction to opps and design (
bhfcvh531
 
Ad

Recently uploaded (20)

Security Tips for Enterprise Azure Solutions
Security Tips for Enterprise Azure Solutions
Michele Leroux Bustamante
 
Powering Multi-Page Web Applications Using Flow Apps and FME Data Streaming
Powering Multi-Page Web Applications Using Flow Apps and FME Data Streaming
Safe Software
 
Securing AI - There Is No Try, Only Do!.pdf
Securing AI - There Is No Try, Only Do!.pdf
Priyanka Aash
 
FIDO Seminar: New Data: Passkey Adoption in the Workforce.pptx
FIDO Seminar: New Data: Passkey Adoption in the Workforce.pptx
FIDO Alliance
 
Lessons Learned from Developing Secure AI Workflows.pdf
Lessons Learned from Developing Secure AI Workflows.pdf
Priyanka Aash
 
“Key Requirements to Successfully Implement Generative AI in Edge Devices—Opt...
“Key Requirements to Successfully Implement Generative AI in Edge Devices—Opt...
Edge AI and Vision Alliance
 
FIDO Alliance Seminar State of Passkeys.pptx
FIDO Alliance Seminar State of Passkeys.pptx
FIDO Alliance
 
UserCon Belgium: Honey, VMware increased my bill
UserCon Belgium: Honey, VMware increased my bill
stijn40
 
Connecting Data and Intelligence: The Role of FME in Machine Learning
Connecting Data and Intelligence: The Role of FME in Machine Learning
Safe Software
 
AI vs Human Writing: Can You Tell the Difference?
AI vs Human Writing: Can You Tell the Difference?
Shashi Sathyanarayana, Ph.D
 
The Future of Technology: 2025-2125 by Saikat Basu.pdf
The Future of Technology: 2025-2125 by Saikat Basu.pdf
Saikat Basu
 
From Manual to Auto Searching- FME in the Driver's Seat
From Manual to Auto Searching- FME in the Driver's Seat
Safe Software
 
OpenPOWER Foundation & Open-Source Core Innovations
OpenPOWER Foundation & Open-Source Core Innovations
IBM
 
GenAI Opportunities and Challenges - Where 370 Enterprises Are Focusing Now.pdf
GenAI Opportunities and Challenges - Where 370 Enterprises Are Focusing Now.pdf
Priyanka Aash
 
Cluster-Based Multi-Objective Metamorphic Test Case Pair Selection for Deep N...
Cluster-Based Multi-Objective Metamorphic Test Case Pair Selection for Deep N...
janeliewang985
 
War_And_Cyber_3_Years_Of_Struggle_And_Lessons_For_Global_Security.pdf
War_And_Cyber_3_Years_Of_Struggle_And_Lessons_For_Global_Security.pdf
biswajitbanerjee38
 
Curietech AI in action - Accelerate MuleSoft development
Curietech AI in action - Accelerate MuleSoft development
shyamraj55
 
Tech-ASan: Two-stage check for Address Sanitizer - Yixuan Cao.pdf
Tech-ASan: Two-stage check for Address Sanitizer - Yixuan Cao.pdf
caoyixuan2019
 
FIDO Seminar: Perspectives on Passkeys & Consumer Adoption.pptx
FIDO Seminar: Perspectives on Passkeys & Consumer Adoption.pptx
FIDO Alliance
 
CapCut Pro Crack For PC Latest Version {Fully Unlocked} 2025
CapCut Pro Crack For PC Latest Version {Fully Unlocked} 2025
pcprocore
 
Security Tips for Enterprise Azure Solutions
Security Tips for Enterprise Azure Solutions
Michele Leroux Bustamante
 
Powering Multi-Page Web Applications Using Flow Apps and FME Data Streaming
Powering Multi-Page Web Applications Using Flow Apps and FME Data Streaming
Safe Software
 
Securing AI - There Is No Try, Only Do!.pdf
Securing AI - There Is No Try, Only Do!.pdf
Priyanka Aash
 
FIDO Seminar: New Data: Passkey Adoption in the Workforce.pptx
FIDO Seminar: New Data: Passkey Adoption in the Workforce.pptx
FIDO Alliance
 
Lessons Learned from Developing Secure AI Workflows.pdf
Lessons Learned from Developing Secure AI Workflows.pdf
Priyanka Aash
 
“Key Requirements to Successfully Implement Generative AI in Edge Devices—Opt...
“Key Requirements to Successfully Implement Generative AI in Edge Devices—Opt...
Edge AI and Vision Alliance
 
FIDO Alliance Seminar State of Passkeys.pptx
FIDO Alliance Seminar State of Passkeys.pptx
FIDO Alliance
 
UserCon Belgium: Honey, VMware increased my bill
UserCon Belgium: Honey, VMware increased my bill
stijn40
 
Connecting Data and Intelligence: The Role of FME in Machine Learning
Connecting Data and Intelligence: The Role of FME in Machine Learning
Safe Software
 
AI vs Human Writing: Can You Tell the Difference?
AI vs Human Writing: Can You Tell the Difference?
Shashi Sathyanarayana, Ph.D
 
The Future of Technology: 2025-2125 by Saikat Basu.pdf
The Future of Technology: 2025-2125 by Saikat Basu.pdf
Saikat Basu
 
From Manual to Auto Searching- FME in the Driver's Seat
From Manual to Auto Searching- FME in the Driver's Seat
Safe Software
 
OpenPOWER Foundation & Open-Source Core Innovations
OpenPOWER Foundation & Open-Source Core Innovations
IBM
 
GenAI Opportunities and Challenges - Where 370 Enterprises Are Focusing Now.pdf
GenAI Opportunities and Challenges - Where 370 Enterprises Are Focusing Now.pdf
Priyanka Aash
 
Cluster-Based Multi-Objective Metamorphic Test Case Pair Selection for Deep N...
Cluster-Based Multi-Objective Metamorphic Test Case Pair Selection for Deep N...
janeliewang985
 
War_And_Cyber_3_Years_Of_Struggle_And_Lessons_For_Global_Security.pdf
War_And_Cyber_3_Years_Of_Struggle_And_Lessons_For_Global_Security.pdf
biswajitbanerjee38
 
Curietech AI in action - Accelerate MuleSoft development
Curietech AI in action - Accelerate MuleSoft development
shyamraj55
 
Tech-ASan: Two-stage check for Address Sanitizer - Yixuan Cao.pdf
Tech-ASan: Two-stage check for Address Sanitizer - Yixuan Cao.pdf
caoyixuan2019
 
FIDO Seminar: Perspectives on Passkeys & Consumer Adoption.pptx
FIDO Seminar: Perspectives on Passkeys & Consumer Adoption.pptx
FIDO Alliance
 
CapCut Pro Crack For PC Latest Version {Fully Unlocked} 2025
CapCut Pro Crack For PC Latest Version {Fully Unlocked} 2025
pcprocore
 
Ad

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: [email protected] [email protected] 15 / 15www.senzil.com