SlideShare a Scribd company logo
Design pattern  factory method
Design pattern  factory method
The client does not care about the
classes implementation, he wants to
get the class that will do his job only.
Client wants to choose one of the
several available objects
I need to implement something
like java class factory that I can
produce the clients needs !!
Object
Object
Object
Object
Object
Object
Object
Object
Object
Object
Object
Object
Object
Java Object Factory
In real world , Factory is : a manufactory that
produce the products to clients , look like Cars
factory , Computer factory … and finally Java
Object factory
• Factory pattern or Factory method pattern is one of the most important and
common pattern in Java under Creational Pattern group .
• Use factory pattern when the creator hide the class creation and instantiation of the
product from the client.
• Client does not care about concrete classes implementation .
• Client can chose one of server available classes ( like product catalog ) and use it
directly without instantiate
• Producer provide an interface to client to use the desired object in his job. .
• Create an Interface for product s use same implementation (TOYOTA)
• Impalement this interface with all products in same category that the factory will
produce (Corolla , Camry , Yaris)
• You can create an abstract class to inherit all shared implementation like “ buy new
car procedures .”
• Create factory method would be responsible for instantiating needed object s
• When the client uses the object , the factory responsible for instantiating the object
Design pattern  factory method

More Related Content

PPTX
Factory Design Pattern
PPT
Factory Method Pattern
PDF
Factory method pattern (Virtual Constructor)
PPTX
Factory Method Pattern
PPTX
Design Pattern - Factory Method Pattern
PPTX
Factory design pattern
PPTX
Design Patterns - Abstract Factory Pattern
PPTX
Factory Design Pattern
Factory Design Pattern
Factory Method Pattern
Factory method pattern (Virtual Constructor)
Factory Method Pattern
Design Pattern - Factory Method Pattern
Factory design pattern
Design Patterns - Abstract Factory Pattern
Factory Design Pattern

What's hot (17)

PDF
Creational abstract factory_design_pattern
PPTX
Desing pattern prototype-Factory Method, Prototype and Builder
PPT
Factory Method Design Pattern
PPTX
Factory Pattern
PDF
Builder Design Pattern (Generic Construction -Different Representation)
PPTX
Factory method pattern
PPTX
Creational pattern
PDF
Design Patterns - Factory Method & Abstract Factory
PPTX
Weekly Meeting: Basic Design Pattern
PPTX
Design pattern (Abstract Factory & Singleton)
PPTX
Design patterns creational patterns
PDF
Webinar on Design Patterns titled 'Dive into Design Patterns'
PPTX
Design Pattern - Introduction
PPT
Structural patterns
PPTX
Design Patterns
PDF
ALPHA Script - XML Generator
PDF
Lab 3: Optional: Creating views at the module level (web client)
Creational abstract factory_design_pattern
Desing pattern prototype-Factory Method, Prototype and Builder
Factory Method Design Pattern
Factory Pattern
Builder Design Pattern (Generic Construction -Different Representation)
Factory method pattern
Creational pattern
Design Patterns - Factory Method & Abstract Factory
Weekly Meeting: Basic Design Pattern
Design pattern (Abstract Factory & Singleton)
Design patterns creational patterns
Webinar on Design Patterns titled 'Dive into Design Patterns'
Design Pattern - Introduction
Structural patterns
Design Patterns
ALPHA Script - XML Generator
Lab 3: Optional: Creating views at the module level (web client)
Ad

Similar to Design pattern factory method (20)

PPTX
Creational Design Patterns.pptx
PPTX
Factory Method Pattern
PPTX
Creational Patterns
PPT
Prototype pattern
PPTX
design patter related ppt and presentation
PPTX
Code Like a Ninja Session 7 - Creational Design Patterns
PPTX
Software Architecture and Design Patterns Notes.pptx
PPTX
PDF
Creational factory design_pattern
PPTX
Adapter Pattern
PPTX
Adapter Design Pattern
PPTX
Introduction to Bitreactive
PPTX
Factory Pattern
PDF
Why Design Patterns Are Important In Software Engineering
PPT
Design Pattern For C# Part 1
PPTX
Super market billing system using webcam
PDF
The Basic Concept Of IOC
PDF
Session 3 - Object oriented programming with Objective-C (part 1)
PDF
Factory pattern in Java
PPTX
#_ varible function
Creational Design Patterns.pptx
Factory Method Pattern
Creational Patterns
Prototype pattern
design patter related ppt and presentation
Code Like a Ninja Session 7 - Creational Design Patterns
Software Architecture and Design Patterns Notes.pptx
Creational factory design_pattern
Adapter Pattern
Adapter Design Pattern
Introduction to Bitreactive
Factory Pattern
Why Design Patterns Are Important In Software Engineering
Design Pattern For C# Part 1
Super market billing system using webcam
The Basic Concept Of IOC
Session 3 - Object oriented programming with Objective-C (part 1)
Factory pattern in Java
#_ varible function
Ad

Recently uploaded (20)

PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PDF
RMMM.pdf make it easy to upload and study
PDF
Computing-Curriculum for Schools in Ghana
PPTX
202450812 BayCHI UCSC-SV 20250812 v17.pptx
PPTX
Presentation on HIE in infants and its manifestations
PPTX
Cell Types and Its function , kingdom of life
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PPTX
Cell Structure & Organelles in detailed.
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PPTX
Lesson notes of climatology university.
PDF
VCE English Exam - Section C Student Revision Booklet
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PDF
Anesthesia in Laparoscopic Surgery in India
PPTX
Institutional Correction lecture only . . .
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PPTX
master seminar digital applications in india
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
Module 4: Burden of Disease Tutorial Slides S2 2025
Abdominal Access Techniques with Prof. Dr. R K Mishra
RMMM.pdf make it easy to upload and study
Computing-Curriculum for Schools in Ghana
202450812 BayCHI UCSC-SV 20250812 v17.pptx
Presentation on HIE in infants and its manifestations
Cell Types and Its function , kingdom of life
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
Cell Structure & Organelles in detailed.
O5-L3 Freight Transport Ops (International) V1.pdf
Lesson notes of climatology university.
VCE English Exam - Section C Student Revision Booklet
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
Anesthesia in Laparoscopic Surgery in India
Institutional Correction lecture only . . .
Supply Chain Operations Speaking Notes -ICLT Program
Final Presentation General Medicine 03-08-2024.pptx
2.FourierTransform-ShortQuestionswithAnswers.pdf
master seminar digital applications in india
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...

Design pattern factory method

  • 3. The client does not care about the classes implementation, he wants to get the class that will do his job only. Client wants to choose one of the several available objects I need to implement something like java class factory that I can produce the clients needs !!
  • 6. In real world , Factory is : a manufactory that produce the products to clients , look like Cars factory , Computer factory … and finally Java Object factory
  • 7. • Factory pattern or Factory method pattern is one of the most important and common pattern in Java under Creational Pattern group . • Use factory pattern when the creator hide the class creation and instantiation of the product from the client. • Client does not care about concrete classes implementation . • Client can chose one of server available classes ( like product catalog ) and use it directly without instantiate • Producer provide an interface to client to use the desired object in his job. .
  • 8. • Create an Interface for product s use same implementation (TOYOTA) • Impalement this interface with all products in same category that the factory will produce (Corolla , Camry , Yaris) • You can create an abstract class to inherit all shared implementation like “ buy new car procedures .” • Create factory method would be responsible for instantiating needed object s • When the client uses the object , the factory responsible for instantiating the object