SlideShare une entreprise Scribd logo
1  sur  15
Factory Method Pattern
  Shahriar Iqbal Chowdhury & Monjurul Habib
        Code Name: Remington



     http://www.facebook.com/groups/netter/
Why We need Factory? Caveman Example
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 method pattern

Contenu connexe

Tendances

Factory design pattern
Factory design patternFactory design pattern
Factory design pattern
Farhad Safarov
 
Factory Pattern
Factory PatternFactory Pattern
Factory Pattern
Deepti C
 

Tendances (17)

Desing pattern prototype-Factory Method, Prototype and Builder
Desing pattern prototype-Factory Method, Prototype and Builder Desing pattern prototype-Factory Method, Prototype and Builder
Desing pattern prototype-Factory Method, Prototype and Builder
 
Factory Design Pattern
Factory Design PatternFactory Design Pattern
Factory Design Pattern
 
Design Patterns - Abstract Factory Pattern
Design Patterns - Abstract Factory PatternDesign Patterns - Abstract Factory Pattern
Design Patterns - Abstract Factory Pattern
 
Factory design pattern
Factory design patternFactory design pattern
Factory design pattern
 
Design Patterns - Factory Method & Abstract Factory
Design Patterns - Factory Method & Abstract FactoryDesign Patterns - Factory Method & Abstract Factory
Design Patterns - Factory Method & Abstract Factory
 
Design pattern (Abstract Factory & Singleton)
Design pattern (Abstract Factory & Singleton)Design pattern (Abstract Factory & Singleton)
Design pattern (Abstract Factory & Singleton)
 
Factory Pattern
Factory PatternFactory Pattern
Factory Pattern
 
Creational pattern
Creational patternCreational pattern
Creational pattern
 
Creational abstract factory_design_pattern
Creational abstract factory_design_patternCreational abstract factory_design_pattern
Creational abstract factory_design_pattern
 
Effective java
Effective javaEffective java
Effective java
 
Effective Java - Chapter 4: Classes and Interfaces
Effective Java - Chapter 4: Classes and InterfacesEffective Java - Chapter 4: Classes and Interfaces
Effective Java - Chapter 4: Classes and Interfaces
 
Creating and destroying objects
Creating and destroying objectsCreating and destroying objects
Creating and destroying objects
 
Design patterns
Design patternsDesign patterns
Design patterns
 
Composite design pattern
Composite design patternComposite design pattern
Composite design pattern
 
Weekly Meeting: Basic Design Pattern
Weekly Meeting: Basic Design PatternWeekly Meeting: Basic Design Pattern
Weekly Meeting: Basic Design Pattern
 
Module 10 : creating and destroying objects
Module 10 : creating and destroying objectsModule 10 : creating and destroying objects
Module 10 : creating and destroying objects
 
Design Pattern - Introduction
Design Pattern - IntroductionDesign Pattern - Introduction
Design Pattern - Introduction
 

Similaire à Factory method pattern

P Training Presentation
P Training PresentationP Training Presentation
P Training Presentation
Gaurav Tyagi
 
The Basic Concept Of IOC
The Basic Concept Of IOCThe Basic Concept Of IOC
The Basic Concept Of IOC
Carl Lu
 

Similaire à Factory method pattern (20)

Creational Design Patterns.pptx
Creational Design Patterns.pptxCreational Design Patterns.pptx
Creational Design Patterns.pptx
 
Factory Method Pattern
Factory Method PatternFactory Method Pattern
Factory Method Pattern
 
Code Like a Ninja Session 7 - Creational Design Patterns
Code Like a Ninja Session 7 - Creational Design PatternsCode Like a Ninja Session 7 - Creational Design Patterns
Code Like a Ninja Session 7 - Creational Design Patterns
 
工廠模式
工廠模式 工廠模式
工廠模式
 
Microsoft Fakes, Unit Testing the (almost) Untestable Code
Microsoft Fakes, Unit Testing the (almost) Untestable CodeMicrosoft Fakes, Unit Testing the (almost) Untestable Code
Microsoft Fakes, Unit Testing the (almost) Untestable Code
 
Unit Tests with Microsoft Fakes
Unit Tests with Microsoft FakesUnit Tests with Microsoft Fakes
Unit Tests with Microsoft Fakes
 
Gof design patterns
Gof design patternsGof design patterns
Gof design patterns
 
Prototype design patterns
Prototype design patternsPrototype design patterns
Prototype design patterns
 
Jump start to OOP, OOAD, and Design Pattern
Jump start to OOP, OOAD, and Design PatternJump start to OOP, OOAD, and Design Pattern
Jump start to OOP, OOAD, and Design Pattern
 
Jump Start To Ooad And Design Patterns
Jump Start To Ooad And Design PatternsJump Start To Ooad And Design Patterns
Jump Start To Ooad And Design Patterns
 
springtraning-7024840-phpapp01.pdf
springtraning-7024840-phpapp01.pdfspringtraning-7024840-phpapp01.pdf
springtraning-7024840-phpapp01.pdf
 
Design p atterns
Design p atternsDesign p atterns
Design p atterns
 
Devday2016 real unittestingwithmockframework-phatvu
Devday2016 real unittestingwithmockframework-phatvuDevday2016 real unittestingwithmockframework-phatvu
Devday2016 real unittestingwithmockframework-phatvu
 
Commonly used design patterns
Commonly used design patternsCommonly used design patterns
Commonly used design patterns
 
Javascript for the c# developer
Javascript for the c# developerJavascript for the c# developer
Javascript for the c# developer
 
P Training Presentation
P Training PresentationP Training Presentation
P Training Presentation
 
The Basic Concept Of IOC
The Basic Concept Of IOCThe Basic Concept Of IOC
The Basic Concept Of IOC
 
Sda 8
Sda   8Sda   8
Sda 8
 
Javascript Common Design Patterns
Javascript Common Design PatternsJavascript Common Design Patterns
Javascript Common Design Patterns
 
Common design patterns in php
Common design patterns in phpCommon design patterns in php
Common design patterns in php
 

Plus de Shahriar Iqbal Chowdhury

Plus de Shahriar Iqbal Chowdhury (14)

Community
CommunityCommunity
Community
 
Cloud friendly Enterprise Architecture
Cloud friendly Enterprise ArchitectureCloud friendly Enterprise Architecture
Cloud friendly Enterprise Architecture
 
Interactive SDLC
Interactive SDLCInteractive SDLC
Interactive SDLC
 
Enterprise business Inteligence
Enterprise business Inteligence Enterprise business Inteligence
Enterprise business Inteligence
 
Big Data
Big DataBig Data
Big Data
 
Cloud Computing
Cloud ComputingCloud Computing
Cloud Computing
 
Version control
Version controlVersion control
Version control
 
Node JS
Node JSNode JS
Node JS
 
Application development gadget & gears
Application development gadget & gearsApplication development gadget & gears
Application development gadget & gears
 
SPA
SPASPA
SPA
 
Design Pattern that every cloud developer must know
Design Pattern that every cloud developer must know Design Pattern that every cloud developer must know
Design Pattern that every cloud developer must know
 
Strategy Pattern
Strategy PatternStrategy Pattern
Strategy Pattern
 
Observer pattern
Observer patternObserver pattern
Observer pattern
 
Adapter Design Pattern
Adapter Design PatternAdapter Design Pattern
Adapter Design Pattern
 

Dernier

Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 

Dernier (20)

Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 

Factory method pattern

Notes de l'éditeur

  1. once upon a time caveman's were happy, their need was small, their hunting gear is big enough for their prey
  2. 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???
  3. Hummm, seems that idea didn't workout well.
  4. Its time to call the hunter and enjoy the meal :)
  5. 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. 
  6. Use Reflection