SlideShare a Scribd company logo
QmPe
                                              initiative




FACTORY PATTERN explained !




                               Prepared by Annamalai C


         Copyright 2006-2011
Factory Pattern in Real Life
Kitchen in a Restaurant is similar to a Factory.
It is the Production House of the Restaurant.
-----------------------------------
Customer places orders from a Menu, doesn’t really know how it gets prepared.
In return to the order, gets a fully cooked dish for eating.




Factory Pattern is a Creational Pattern.
It helps in Object Creation without exposing the details of Creation.




                                     Copyright 2006-2011
Factory Pattern in Java




                          Copyright 2006-2011
Real Life vs Java Object




                                                 Factory




                                                 Kitchen




                           Copyright 2006-2011
Real Life vs Java Object




                           Copyright 2006-2011
How Factory Pattern works in Real Life ?


               1   Orders a Dish from Menu




                                                                 Receives the Name of the Dish
                                                             2   Creates the Dish


               3   Delivers the Dish




                                       Copyright 2006-2011
How Factory Pattern works in Java ?

                                                               public Food getFood(String name) {
                                                                 if (name.equals("Dosa")) {
                                                                   return new Dosa();
                   1                                             } else if (name.equals("Noodles")) {
                                                                   return new Noodles();
                                                                 }
                                                                 return null;
                                                               }

KitchenFactory factory = new KitchenFactory();
Food dosa = factory.getFood("Dosa");
dosa.print();
                                                                             2
Food noodles = factory.getFood("Noodles");
noodles.print();




                                                                           Food

                  3
                                                                   Dosa            Noodles



                                             Copyright 2006-2011
THANK YOU


                   Please visit
www.eclipseinclips.com | www.ancitconsulting.com

     Write to us on info@ancitconsulting.com




                  QmPe
                  initiative


                   Copyright 2006-2011

More Related Content

Viewers also liked

1 detail plan restaurant
1 detail plan restaurant1 detail plan restaurant
1 detail plan restaurant
dezyneecole
 
Blue Sky Factory: Email & Social Media - Community, Content & Killer Campaigns
Blue Sky Factory: Email & Social Media - Community, Content & Killer CampaignsBlue Sky Factory: Email & Social Media - Community, Content & Killer Campaigns
Blue Sky Factory: Email & Social Media - Community, Content & Killer Campaigns
Blue Sky Factory
 
Factory life
Factory lifeFactory life
Factory life
James Simpson
 
Event point resort @ varasandra near NICE covered leaf Bangalore
Event point resort @ varasandra near NICE covered leaf BangaloreEvent point resort @ varasandra near NICE covered leaf Bangalore
Event point resort @ varasandra near NICE covered leaf Bangalore
Azam FA
 
Other industrial changes
Other industrial changesOther industrial changes
Other industrial changes
James Simpson
 
Restaurant atomsphere
Restaurant atomsphereRestaurant atomsphere
Restaurant atomsphere
Yamini Soni
 

Viewers also liked (6)

1 detail plan restaurant
1 detail plan restaurant1 detail plan restaurant
1 detail plan restaurant
 
Blue Sky Factory: Email & Social Media - Community, Content & Killer Campaigns
Blue Sky Factory: Email & Social Media - Community, Content & Killer CampaignsBlue Sky Factory: Email & Social Media - Community, Content & Killer Campaigns
Blue Sky Factory: Email & Social Media - Community, Content & Killer Campaigns
 
Factory life
Factory lifeFactory life
Factory life
 
Event point resort @ varasandra near NICE covered leaf Bangalore
Event point resort @ varasandra near NICE covered leaf BangaloreEvent point resort @ varasandra near NICE covered leaf Bangalore
Event point resort @ varasandra near NICE covered leaf Bangalore
 
Other industrial changes
Other industrial changesOther industrial changes
Other industrial changes
 
Restaurant atomsphere
Restaurant atomsphereRestaurant atomsphere
Restaurant atomsphere
 

More from Annamalai Chockalingam

Hello world e4 application part 5
Hello world e4 application   part 5Hello world e4 application   part 5
Hello world e4 application part 5
Annamalai Chockalingam
 
Hello World e4 Application Part 7
Hello World e4 Application Part 7Hello World e4 Application Part 7
Hello World e4 Application Part 7
Annamalai Chockalingam
 
Hello World e4 Application Part 6
Hello World e4 Application Part 6Hello World e4 Application Part 6
Hello World e4 Application Part 6
Annamalai Chockalingam
 
Hello World e4 Application Part 2
Hello World e4 Application   Part 2Hello World e4 Application   Part 2
Hello World e4 Application Part 2
Annamalai Chockalingam
 
Hello World e4 Application Part 3
Hello World e4 Application  Part 3Hello World e4 Application  Part 3
Hello World e4 Application Part 3
Annamalai Chockalingam
 
Design patterns - Strategy Pattern
Design patterns - Strategy PatternDesign patterns - Strategy Pattern
Design patterns - Strategy Pattern
Annamalai Chockalingam
 
Design patterns - Observer Pattern
Design patterns - Observer PatternDesign patterns - Observer Pattern
Design patterns - Observer Pattern
Annamalai Chockalingam
 
Design patterns - Decorator pattern
Design patterns -   Decorator patternDesign patterns -   Decorator pattern
Design patterns - Decorator pattern
Annamalai Chockalingam
 
Design patterns - Adapter Pattern
Design patterns - Adapter PatternDesign patterns - Adapter Pattern
Design patterns - Adapter Pattern
Annamalai Chockalingam
 
Eclipse Spykit Project
Eclipse Spykit ProjectEclipse Spykit Project
Eclipse Spykit Project
Annamalai Chockalingam
 
Setting up Sphinx Development Environment
Setting up Sphinx Development EnvironmentSetting up Sphinx Development Environment
Setting up Sphinx Development Environment
Annamalai Chockalingam
 
Eclipse Ecosystem in India
Eclipse Ecosystem in IndiaEclipse Ecosystem in India
Eclipse Ecosystem in India
Annamalai Chockalingam
 

More from Annamalai Chockalingam (12)

Hello world e4 application part 5
Hello world e4 application   part 5Hello world e4 application   part 5
Hello world e4 application part 5
 
Hello World e4 Application Part 7
Hello World e4 Application Part 7Hello World e4 Application Part 7
Hello World e4 Application Part 7
 
Hello World e4 Application Part 6
Hello World e4 Application Part 6Hello World e4 Application Part 6
Hello World e4 Application Part 6
 
Hello World e4 Application Part 2
Hello World e4 Application   Part 2Hello World e4 Application   Part 2
Hello World e4 Application Part 2
 
Hello World e4 Application Part 3
Hello World e4 Application  Part 3Hello World e4 Application  Part 3
Hello World e4 Application Part 3
 
Design patterns - Strategy Pattern
Design patterns - Strategy PatternDesign patterns - Strategy Pattern
Design patterns - Strategy Pattern
 
Design patterns - Observer Pattern
Design patterns - Observer PatternDesign patterns - Observer Pattern
Design patterns - Observer Pattern
 
Design patterns - Decorator pattern
Design patterns -   Decorator patternDesign patterns -   Decorator pattern
Design patterns - Decorator pattern
 
Design patterns - Adapter Pattern
Design patterns - Adapter PatternDesign patterns - Adapter Pattern
Design patterns - Adapter Pattern
 
Eclipse Spykit Project
Eclipse Spykit ProjectEclipse Spykit Project
Eclipse Spykit Project
 
Setting up Sphinx Development Environment
Setting up Sphinx Development EnvironmentSetting up Sphinx Development Environment
Setting up Sphinx Development Environment
 
Eclipse Ecosystem in India
Eclipse Ecosystem in IndiaEclipse Ecosystem in India
Eclipse Ecosystem in India
 

Recently uploaded

Biomedical Knowledge Graphs for Data Scientists and Bioinformaticians
Biomedical Knowledge Graphs for Data Scientists and BioinformaticiansBiomedical Knowledge Graphs for Data Scientists and Bioinformaticians
Biomedical Knowledge Graphs for Data Scientists and Bioinformaticians
Neo4j
 
GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)
Javier Junquera
 
"Choosing proper type of scaling", Olena Syrota
"Choosing proper type of scaling", Olena Syrota"Choosing proper type of scaling", Olena Syrota
"Choosing proper type of scaling", Olena Syrota
Fwdays
 
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
saastr
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
panagenda
 
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectorsConnector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
DianaGray10
 
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
Jason Yip
 
Essentials of Automations: Exploring Attributes & Automation Parameters
Essentials of Automations: Exploring Attributes & Automation ParametersEssentials of Automations: Exploring Attributes & Automation Parameters
Essentials of Automations: Exploring Attributes & Automation Parameters
Safe Software
 
The Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptxThe Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptx
operationspcvita
 
Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving | Nameplate Manufacturing Process - 2024Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving
 
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
saastr
 
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development ProvidersYour One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
akankshawande
 
Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |
AstuteBusiness
 
Leveraging the Graph for Clinical Trials and Standards
Leveraging the Graph for Clinical Trials and StandardsLeveraging the Graph for Clinical Trials and Standards
Leveraging the Graph for Clinical Trials and Standards
Neo4j
 
Choosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptxChoosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptx
Brandon Minnick, MBA
 
Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
MichaelKnudsen27
 
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
Pitangent Analytics & Technology Solutions Pvt. Ltd
 
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
Edge AI and Vision Alliance
 
JavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green MasterplanJavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green Masterplan
Miro Wengner
 
Taking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdfTaking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdf
ssuserfac0301
 

Recently uploaded (20)

Biomedical Knowledge Graphs for Data Scientists and Bioinformaticians
Biomedical Knowledge Graphs for Data Scientists and BioinformaticiansBiomedical Knowledge Graphs for Data Scientists and Bioinformaticians
Biomedical Knowledge Graphs for Data Scientists and Bioinformaticians
 
GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)
 
"Choosing proper type of scaling", Olena Syrota
"Choosing proper type of scaling", Olena Syrota"Choosing proper type of scaling", Olena Syrota
"Choosing proper type of scaling", Olena Syrota
 
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
 
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectorsConnector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
 
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
 
Essentials of Automations: Exploring Attributes & Automation Parameters
Essentials of Automations: Exploring Attributes & Automation ParametersEssentials of Automations: Exploring Attributes & Automation Parameters
Essentials of Automations: Exploring Attributes & Automation Parameters
 
The Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptxThe Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptx
 
Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving | Nameplate Manufacturing Process - 2024Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving | Nameplate Manufacturing Process - 2024
 
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
 
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development ProvidersYour One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
 
Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |Astute Business Solutions | Oracle Cloud Partner |
Astute Business Solutions | Oracle Cloud Partner |
 
Leveraging the Graph for Clinical Trials and Standards
Leveraging the Graph for Clinical Trials and StandardsLeveraging the Graph for Clinical Trials and Standards
Leveraging the Graph for Clinical Trials and Standards
 
Choosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptxChoosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptx
 
Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
 
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
 
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
“Temporal Event Neural Networks: A More Efficient Alternative to the Transfor...
 
JavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green MasterplanJavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green Masterplan
 
Taking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdfTaking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdf
 

Design patterns - Factory Pattern

  • 1. QmPe initiative FACTORY PATTERN explained ! Prepared by Annamalai C Copyright 2006-2011
  • 2. Factory Pattern in Real Life Kitchen in a Restaurant is similar to a Factory. It is the Production House of the Restaurant. ----------------------------------- Customer places orders from a Menu, doesn’t really know how it gets prepared. In return to the order, gets a fully cooked dish for eating. Factory Pattern is a Creational Pattern. It helps in Object Creation without exposing the details of Creation. Copyright 2006-2011
  • 3. Factory Pattern in Java Copyright 2006-2011
  • 4. Real Life vs Java Object Factory Kitchen Copyright 2006-2011
  • 5. Real Life vs Java Object Copyright 2006-2011
  • 6. How Factory Pattern works in Real Life ? 1 Orders a Dish from Menu Receives the Name of the Dish 2 Creates the Dish 3 Delivers the Dish Copyright 2006-2011
  • 7. How Factory Pattern works in Java ? public Food getFood(String name) { if (name.equals("Dosa")) { return new Dosa(); 1 } else if (name.equals("Noodles")) { return new Noodles(); } return null; } KitchenFactory factory = new KitchenFactory(); Food dosa = factory.getFood("Dosa"); dosa.print(); 2 Food noodles = factory.getFood("Noodles"); noodles.print(); Food 3 Dosa Noodles Copyright 2006-2011
  • 8. THANK YOU Please visit www.eclipseinclips.com | www.ancitconsulting.com Write to us on info@ancitconsulting.com QmPe initiative Copyright 2006-2011