際際滷

際際滷Share a Scribd company logo
QmPe
                                                   initiative




ABSTRACT FACTORY PATTERN explained !




                                    Prepared by Annamalai C


              Copyright 2006-2011
Abstract Factory Pattern in Real Life
Abstract Factory Pattern is similar to Sub Contracting in real world.
Basically delegating the creation of Objects to expert Factories
-----------------------------------
Orders in a restaurant are received by a Kitchen.
Then are assigned to Special Chefs like
Chinese, Indian, Continental.




Abstract Factory Pattern is a Creational Pattern.
Similar to Factory Pattern it is Object Creation without exposing HOW ?




                                    Copyright 2006-2011
Abstract 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 Order
                                                      2      Creates the Dish


                                                                                  3   Outsources to Chef
               4   Delivers the Dish




                                       Copyright 2006-2011
How Factory Pattern works in Java ?

                                                               public Food getFood(String name) {
                                                                 if (name.equals("Dosa")) {
                                                                   IndianFactory factory = new IndianFactory();
                   1                                               return factory.getFood(name);
                                                               } else if (name.equals("Noodles")) {
                                                                 ChineseFactory factory = new
                                                               ChineseFactory();
                                                                 return factory.getFood(name);
                                                               }
KitchenFactory factory = new KitchenFactory();                 Return null;}
Food dosa = factory.getFood("Dosa");                                              2
dosa.print();
                                                            Create food from Respective Factory Class
Food noodles = factory.getFood("Noodles");
noodles.print();

                                                                                  3

                                                                           Food

                  4
                                                                   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

More from Annamalai Chockalingam (8)

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

Recently uploaded (20)

Transactional Outbox & Inbox Patterns.pptx
Transactional Outbox & Inbox Patterns.pptxTransactional Outbox & Inbox Patterns.pptx
Transactional Outbox & Inbox Patterns.pptx
Maysam Mousa
FutureProofing the Nordic Economy with GenAI
FutureProofing the Nordic Economy with GenAIFutureProofing the Nordic Economy with GenAI
FutureProofing the Nordic Economy with GenAI
Pete Nieminen
Handout - Demonolithing Think Again (Devoxx GR 2025).pdf
Handout - Demonolithing Think Again (Devoxx GR 2025).pdfHandout - Demonolithing Think Again (Devoxx GR 2025).pdf
Handout - Demonolithing Think Again (Devoxx GR 2025).pdf
Scott Sosna
SaaS Product Development Best Practices
SaaS Product Development Best PracticesSaaS Product Development Best Practices
SaaS Product Development Best Practices
ApptDev
Codequiry: A Code Similarity Checker Every Developer Should Know
Codequiry: A Code Similarity Checker Every Developer Should KnowCodequiry: A Code Similarity Checker Every Developer Should Know
Codequiry: A Code Similarity Checker Every Developer Should Know
Code Quiry
Introduction to Mobile App Development.
Introduction to  Mobile App Development.Introduction to  Mobile App Development.
Introduction to Mobile App Development.
AkashDwivedi43
How to Achieve High-Accuracy Results When Using LLMs
How to Achieve High-Accuracy Results When Using LLMsHow to Achieve High-Accuracy Results When Using LLMs
How to Achieve High-Accuracy Results When Using LLMs
Aggregage
Atlassian Community - Human-Centered AI in Product Management Unleashing Inno...
Atlassian Community - Human-Centered AI in Product Management Unleashing Inno...Atlassian Community - Human-Centered AI in Product Management Unleashing Inno...
Atlassian Community - Human-Centered AI in Product Management Unleashing Inno...
Buwaneka De Silva
Build With AI X GDG Harare Beginners .pdf
Build With AI X GDG Harare Beginners .pdfBuild With AI X GDG Harare Beginners .pdf
Build With AI X GDG Harare Beginners .pdf
Google Developer Group - Harare
Cloudflares Game-Changing Move The First Remote MCP Server for AI Agent Deve...
Cloudflares Game-Changing Move The First Remote MCP Server for AI Agent Deve...Cloudflares Game-Changing Move The First Remote MCP Server for AI Agent Deve...
Cloudflares Game-Changing Move The First Remote MCP Server for AI Agent Deve...
davidandersonofficia
Introduction to PHP from Beginning to End
Introduction to PHP from Beginning to EndIntroduction to PHP from Beginning to End
Introduction to PHP from Beginning to End
christopherneo4
New from BookNet Canada for 2025: BNC SalesData and BNC LibraryData
New from BookNet Canada for 2025: BNC SalesData and BNC LibraryDataNew from BookNet Canada for 2025: BNC SalesData and BNC LibraryData
New from BookNet Canada for 2025: BNC SalesData and BNC LibraryData
BookNet Canada
From SBOMs to xBOMs to Transparency - Pavel Shukhman at OWASP Ottawa on 2025-...
From SBOMs to xBOMs to Transparency - Pavel Shukhman at OWASP Ottawa on 2025-...From SBOMs to xBOMs to Transparency - Pavel Shukhman at OWASP Ottawa on 2025-...
From SBOMs to xBOMs to Transparency - Pavel Shukhman at OWASP Ottawa on 2025-...
Pavel Shukhman
Presentation Session 4 -Agent Builder.pdf
Presentation Session 4 -Agent Builder.pdfPresentation Session 4 -Agent Builder.pdf
Presentation Session 4 -Agent Builder.pdf
Mukesh Kala
TNBC Research Presentation and medical virology .pptx
TNBC Research Presentation and medical virology .pptxTNBC Research Presentation and medical virology .pptx
TNBC Research Presentation and medical virology .pptx
MohamedHasan816582
UiPath Community Dubai: Discover Unified Apps
UiPath Community Dubai: Discover Unified AppsUiPath Community Dubai: Discover Unified Apps
UiPath Community Dubai: Discover Unified Apps
UiPathCommunity
Health Promotion explained ppt.pptx
Health Promotion  explained ppt.pptxHealth Promotion  explained ppt.pptx
Health Promotion explained ppt.pptx
MohamedIbrahim354734
Ricardo Jebb Bruno - A Structural CAD Technician
Ricardo Jebb Bruno - A Structural CAD TechnicianRicardo Jebb Bruno - A Structural CAD Technician
Ricardo Jebb Bruno - A Structural CAD Technician
Ricardo Jebb Bruno
AI Driven Posture Analysis Fall Detection System for the Elderly.pdf
AI Driven Posture Analysis Fall Detection System for the Elderly.pdfAI Driven Posture Analysis Fall Detection System for the Elderly.pdf
AI Driven Posture Analysis Fall Detection System for the Elderly.pdf
Patrick Ogbuitepu
A Dell PowerStore shared storage solution is more cost-effective than an HCI ...
A Dell PowerStore shared storage solution is more cost-effective than an HCI ...A Dell PowerStore shared storage solution is more cost-effective than an HCI ...
A Dell PowerStore shared storage solution is more cost-effective than an HCI ...
Principled Technologies
Transactional Outbox & Inbox Patterns.pptx
Transactional Outbox & Inbox Patterns.pptxTransactional Outbox & Inbox Patterns.pptx
Transactional Outbox & Inbox Patterns.pptx
Maysam Mousa
FutureProofing the Nordic Economy with GenAI
FutureProofing the Nordic Economy with GenAIFutureProofing the Nordic Economy with GenAI
FutureProofing the Nordic Economy with GenAI
Pete Nieminen
Handout - Demonolithing Think Again (Devoxx GR 2025).pdf
Handout - Demonolithing Think Again (Devoxx GR 2025).pdfHandout - Demonolithing Think Again (Devoxx GR 2025).pdf
Handout - Demonolithing Think Again (Devoxx GR 2025).pdf
Scott Sosna
SaaS Product Development Best Practices
SaaS Product Development Best PracticesSaaS Product Development Best Practices
SaaS Product Development Best Practices
ApptDev
Codequiry: A Code Similarity Checker Every Developer Should Know
Codequiry: A Code Similarity Checker Every Developer Should KnowCodequiry: A Code Similarity Checker Every Developer Should Know
Codequiry: A Code Similarity Checker Every Developer Should Know
Code Quiry
Introduction to Mobile App Development.
Introduction to  Mobile App Development.Introduction to  Mobile App Development.
Introduction to Mobile App Development.
AkashDwivedi43
How to Achieve High-Accuracy Results When Using LLMs
How to Achieve High-Accuracy Results When Using LLMsHow to Achieve High-Accuracy Results When Using LLMs
How to Achieve High-Accuracy Results When Using LLMs
Aggregage
Atlassian Community - Human-Centered AI in Product Management Unleashing Inno...
Atlassian Community - Human-Centered AI in Product Management Unleashing Inno...Atlassian Community - Human-Centered AI in Product Management Unleashing Inno...
Atlassian Community - Human-Centered AI in Product Management Unleashing Inno...
Buwaneka De Silva
Cloudflares Game-Changing Move The First Remote MCP Server for AI Agent Deve...
Cloudflares Game-Changing Move The First Remote MCP Server for AI Agent Deve...Cloudflares Game-Changing Move The First Remote MCP Server for AI Agent Deve...
Cloudflares Game-Changing Move The First Remote MCP Server for AI Agent Deve...
davidandersonofficia
Introduction to PHP from Beginning to End
Introduction to PHP from Beginning to EndIntroduction to PHP from Beginning to End
Introduction to PHP from Beginning to End
christopherneo4
New from BookNet Canada for 2025: BNC SalesData and BNC LibraryData
New from BookNet Canada for 2025: BNC SalesData and BNC LibraryDataNew from BookNet Canada for 2025: BNC SalesData and BNC LibraryData
New from BookNet Canada for 2025: BNC SalesData and BNC LibraryData
BookNet Canada
From SBOMs to xBOMs to Transparency - Pavel Shukhman at OWASP Ottawa on 2025-...
From SBOMs to xBOMs to Transparency - Pavel Shukhman at OWASP Ottawa on 2025-...From SBOMs to xBOMs to Transparency - Pavel Shukhman at OWASP Ottawa on 2025-...
From SBOMs to xBOMs to Transparency - Pavel Shukhman at OWASP Ottawa on 2025-...
Pavel Shukhman
Presentation Session 4 -Agent Builder.pdf
Presentation Session 4 -Agent Builder.pdfPresentation Session 4 -Agent Builder.pdf
Presentation Session 4 -Agent Builder.pdf
Mukesh Kala
TNBC Research Presentation and medical virology .pptx
TNBC Research Presentation and medical virology .pptxTNBC Research Presentation and medical virology .pptx
TNBC Research Presentation and medical virology .pptx
MohamedHasan816582
UiPath Community Dubai: Discover Unified Apps
UiPath Community Dubai: Discover Unified AppsUiPath Community Dubai: Discover Unified Apps
UiPath Community Dubai: Discover Unified Apps
UiPathCommunity
Health Promotion explained ppt.pptx
Health Promotion  explained ppt.pptxHealth Promotion  explained ppt.pptx
Health Promotion explained ppt.pptx
MohamedIbrahim354734
Ricardo Jebb Bruno - A Structural CAD Technician
Ricardo Jebb Bruno - A Structural CAD TechnicianRicardo Jebb Bruno - A Structural CAD Technician
Ricardo Jebb Bruno - A Structural CAD Technician
Ricardo Jebb Bruno
AI Driven Posture Analysis Fall Detection System for the Elderly.pdf
AI Driven Posture Analysis Fall Detection System for the Elderly.pdfAI Driven Posture Analysis Fall Detection System for the Elderly.pdf
AI Driven Posture Analysis Fall Detection System for the Elderly.pdf
Patrick Ogbuitepu
A Dell PowerStore shared storage solution is more cost-effective than an HCI ...
A Dell PowerStore shared storage solution is more cost-effective than an HCI ...A Dell PowerStore shared storage solution is more cost-effective than an HCI ...
A Dell PowerStore shared storage solution is more cost-effective than an HCI ...
Principled Technologies

Design patterns - Abstract Factory Pattern

  • 1. QmPe initiative ABSTRACT FACTORY PATTERN explained ! Prepared by Annamalai C Copyright 2006-2011
  • 2. Abstract Factory Pattern in Real Life Abstract Factory Pattern is similar to Sub Contracting in real world. Basically delegating the creation of Objects to expert Factories ----------------------------------- Orders in a restaurant are received by a Kitchen. Then are assigned to Special Chefs like Chinese, Indian, Continental. Abstract Factory Pattern is a Creational Pattern. Similar to Factory Pattern it is Object Creation without exposing HOW ? Copyright 2006-2011
  • 3. Abstract 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 Order 2 Creates the Dish 3 Outsources to Chef 4 Delivers the Dish Copyright 2006-2011
  • 7. How Factory Pattern works in Java ? public Food getFood(String name) { if (name.equals("Dosa")) { IndianFactory factory = new IndianFactory(); 1 return factory.getFood(name); } else if (name.equals("Noodles")) { ChineseFactory factory = new ChineseFactory(); return factory.getFood(name); } KitchenFactory factory = new KitchenFactory(); Return null;} Food dosa = factory.getFood("Dosa"); 2 dosa.print(); Create food from Respective Factory Class Food noodles = factory.getFood("Noodles"); noodles.print(); 3 Food 4 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