SlideShare a Scribd company logo
Factory Method Pattern
  Shahriar Iqbal Chowdhury & Monjurul Habib
        Code Name: Remington



     http://www.facebook.com/groups/netter/
Why We need Factory? Caveman Example
Factory Pattern
The Solution
A specialist for the job
Factory Pattern Method Basics
• Creational Pattern
• Which object to create
• It lets a class defer instantiation to subclasses.
• Absolutely all constructors should be private or protected
• Also known as Virtual Constructor.
When to consider?
• When we have a class that implements an interface but not sure
  which object, which concrete instantiation / implementation need to
  return.
• When we need to separate instantiation from the representation.
• When we have lots of select and switch statements for deciding
  which concrete class to create and return.
Factory Says

Define an interface for creating an object, but let subclasses decide which class to instantiate
Problem without Factory Method Pattern
Solution Applying Factory Method Pattern
Banking Account Management System
Object is created based on
configuration parameters
Violation of OCP
(Open Close
Principle of SOLID)
we will need to create a property that indicates type in each account class
Factory Pattern

More Related Content

PPTX
Factory method pattern
PDF
Creational abstract factory_design_pattern
PPTX
Weekly Meeting: Basic Design Pattern
PPTX
Factory design pattern
PDF
Design Patterns - Factory Method & Abstract Factory
PPTX
Design Pattern - Factory Method Pattern
PPTX
Factory Design Pattern
PDF
Design pattern factory method
Factory method pattern
Creational abstract factory_design_pattern
Weekly Meeting: Basic Design Pattern
Factory design pattern
Design Patterns - Factory Method & Abstract Factory
Design Pattern - Factory Method Pattern
Factory Design Pattern
Design pattern factory method

What's hot (16)

PDF
Creational factory design_pattern
PPTX
Factory Design Pattern
PDF
Factory method pattern (Virtual Constructor)
PPTX
Design Patterns - Abstract Factory Pattern
PPT
Factory Method Design Pattern
PPTX
Desing pattern prototype-Factory Method, Prototype and Builder
PPTX
Design pattern (Abstract Factory & Singleton)
PPTX
Factory Pattern
PPT
Factory Method Pattern
PPTX
Tests supporting multiple mobile platforms
PPTX
Adapter Design Pattern
PPTX
Factory Method Pattern
PPTX
OOP's Part 1
PDF
工廠模式
PPTX
EMF Scaffolding
PDF
Styled Components & React.js
Creational factory design_pattern
Factory Design Pattern
Factory method pattern (Virtual Constructor)
Design Patterns - Abstract Factory Pattern
Factory Method Design Pattern
Desing pattern prototype-Factory Method, Prototype and Builder
Design pattern (Abstract Factory & Singleton)
Factory Pattern
Factory Method Pattern
Tests supporting multiple mobile platforms
Adapter Design Pattern
Factory Method Pattern
OOP's Part 1
工廠模式
EMF Scaffolding
Styled Components & React.js
Ad

Viewers also liked (20)

PDF
Design Patterns in Cocoa Touch
PPT
Design patterns - Abstract Factory Pattern
ODP
Design Pattern - 2. Observer
PPTX
Observer pattern, delegate, event, lambda expression
PDF
The Observer Pattern (Definition using UML)
PPTX
Design patterns
PPTX
Observer & singleton pattern
PDF
Observer pattern
PPT
Design patterns 4 - observer pattern
PDF
Design Patterns
PPT
Observer Pattern Khali Young 2006 Aug
PPTX
Design patterns: observer pattern
PPTX
Observer pattern
PPTX
Reflective portfolio
PPT
Design patterns - Observer Pattern
PPTX
Design Pattern - Observer Pattern
PPSX
Observer design pattern
PDF
Observer Pattern
PPTX
Observer pattern
PDF
Observer design pattern
Design Patterns in Cocoa Touch
Design patterns - Abstract Factory Pattern
Design Pattern - 2. Observer
Observer pattern, delegate, event, lambda expression
The Observer Pattern (Definition using UML)
Design patterns
Observer & singleton pattern
Observer pattern
Design patterns 4 - observer pattern
Design Patterns
Observer Pattern Khali Young 2006 Aug
Design patterns: observer pattern
Observer pattern
Reflective portfolio
Design patterns - Observer Pattern
Design Pattern - Observer Pattern
Observer design pattern
Observer Pattern
Observer pattern
Observer design pattern
Ad

Similar to Factory Pattern (20)

PPTX
design patter related ppt and presentation
PPTX
Creational Design Patterns.pptx
PPTX
Factory Method Pattern
PPTX
Code Like a Ninja Session 7 - Creational Design Patterns
PPTX
Microsoft Fakes, Unit Testing the (almost) Untestable Code
PPTX
Unit Tests with Microsoft Fakes
PPTX
Effective java
PPTX
Gof design patterns
PPTX
Prototype design patterns
PPS
Jump start to OOP, OOAD, and Design Pattern
PPT
Jump Start To Ooad And Design Patterns
PDF
springtraning-7024840-phpapp01.pdf
PPTX
Design p atterns
PDF
Devday2016 real unittestingwithmockframework-phatvu
PDF
Commonly used design patterns
PPTX
Javascript for the c# developer
PPT
P Training Presentation
PDF
The Basic Concept Of IOC
PPTX
PDF
Java Design Patterns Interview Questions PDF By ScholarHat
design patter related ppt and presentation
Creational Design Patterns.pptx
Factory Method Pattern
Code Like a Ninja Session 7 - Creational Design Patterns
Microsoft Fakes, Unit Testing the (almost) Untestable Code
Unit Tests with Microsoft Fakes
Effective java
Gof design patterns
Prototype design patterns
Jump start to OOP, OOAD, and Design Pattern
Jump Start To Ooad And Design Patterns
springtraning-7024840-phpapp01.pdf
Design p atterns
Devday2016 real unittestingwithmockframework-phatvu
Commonly used design patterns
Javascript for the c# developer
P Training Presentation
The Basic Concept Of IOC
Java Design Patterns Interview Questions PDF By ScholarHat

Recently uploaded (20)

PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Electronic commerce courselecture one. Pdf
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Machine learning based COVID-19 study performance prediction
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
A Presentation on Artificial Intelligence
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Encapsulation_ Review paper, used for researhc scholars
PPTX
sap open course for s4hana steps from ECC to s4
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
cuic standard and advanced reporting.pdf
PDF
Approach and Philosophy of On baking technology
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Assigned Numbers - 2025 - Bluetooth® Document
Dropbox Q2 2025 Financial Results & Investor Presentation
Electronic commerce courselecture one. Pdf
Digital-Transformation-Roadmap-for-Companies.pptx
Spectral efficient network and resource selection model in 5G networks
Machine learning based COVID-19 study performance prediction
Diabetes mellitus diagnosis method based random forest with bat algorithm
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Reach Out and Touch Someone: Haptics and Empathic Computing
A Presentation on Artificial Intelligence
Advanced methodologies resolving dimensionality complications for autism neur...
Encapsulation_ Review paper, used for researhc scholars
sap open course for s4hana steps from ECC to s4
The AUB Centre for AI in Media Proposal.docx
Building Integrated photovoltaic BIPV_UPV.pdf
20250228 LYD VKU AI Blended-Learning.pptx
cuic standard and advanced reporting.pdf
Approach and Philosophy of On baking technology
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Assigned Numbers - 2025 - Bluetooth® Document

Factory Pattern

Editor's Notes

  • #3: once upon a time caveman's were happy, their need was small, their hunting gear is big enough for their prey
  • #4: Soon their more mouth to feed, with that amount of hunting they can do only one thing!! Cutting... OR hunting bigger prey. Is that easy???
  • #5: Hummm, seems that idea didn't workout well.
  • #6: Its time to call the hunter and enjoy the meal :)
  • #9: The client is an object that requires an instance of another object for some purpose. Rather than creating the product instance directly, the client delegates this responsibility to the factory. Once invoked, the factory creates a new instance of the product, passing it back to the client. Put simply, the client uses the factory to create an instance of the product. 
  • #16: Use Reflection