SlideShare a Scribd company logo

Design Pattern with Burger

Jun Shimizu
Jun Shimizu
Jun ShimizuCEO / DIRECTOR at PT. Buzoo Indonesia

PT.BUZOO INDONESIA is No1 Japanese offshore development company in Indonesia. We are professional of web solution and smartphone apps. We can support Japanese, English and Indonesia. We are hiring now at http://buzoo.co.id/

Design Pattern with Burger

1 of 25
Download to read offline
By Irwan Fathurrahman
Design Pattern with Burger
Order Burger

prepare

bake

presentation

filling
Public Burger orderBurger(){
Burger burger = new Burger();
burger.prepare();
burger.bake();
burger.filling();
burger.presentation();

Our store can take
and give the order.
This is the simple way
for our function to
take order based of
strategy in previous
slide

return burger;

}
But our store just have
one kind of Burger!
We have to create 4 menu!
Public Burger orderBurger(String type){
Burger burger;
if(type == “cheese”){
burger = new CheeseBurger();
} else if(type == “double cheese”){
burger = new DoubleCheeseBurger();
} else if(type == “beef”){
burger = new BeefBurger();
} else if(type == “doublebeef”){
burger = new DoubleBeefBurger();
}

That it!
Our store can take 4
kind of Burger.
- Cheese Burger
- Double Cheese
Burger
- Beef Burger
- Double Beef Burger

burger.prepare();
burger.bake();
burger.filling();
burger.presentation();
return burger;
}

Recommended

Employee Development Plan PowerPoint Presentation Slides
Employee Development Plan PowerPoint Presentation Slides Employee Development Plan PowerPoint Presentation Slides
Employee Development Plan PowerPoint Presentation Slides SlideTeam
 
AKHILESH KUMAR PANDEY AGM HUMAN RESORCES
AKHILESH KUMAR PANDEY AGM HUMAN RESORCES AKHILESH KUMAR PANDEY AGM HUMAN RESORCES
AKHILESH KUMAR PANDEY AGM HUMAN RESORCES AKHILESH KUMAR PANDEY
 
Training and development
Training and developmentTraining and development
Training and developmentAkshatChauhan13
 
Talent Acquisition KPI Scorecard
Talent Acquisition KPI ScorecardTalent Acquisition KPI Scorecard
Talent Acquisition KPI ScorecardRob McIntosh
 
Competency mapping of two job descrptions
Competency mapping of two job descrptionsCompetency mapping of two job descrptions
Competency mapping of two job descrptionsAshok Kumar Venkata
 
Career development-programs
Career development-programsCareer development-programs
Career development-programsBenny Girsang
 
Human Resources Management Process PowerPoint Presentation Slides
Human Resources Management Process PowerPoint Presentation Slides Human Resources Management Process PowerPoint Presentation Slides
Human Resources Management Process PowerPoint Presentation Slides SlideTeam
 

More Related Content

What's hot

Role of a trainer ppt @ bec doms mba
Role of a trainer ppt @ bec doms mbaRole of a trainer ppt @ bec doms mba
Role of a trainer ppt @ bec doms mbaBabasab Patil
 
Paradigm shift - Building a new talent management model to boost growth
Paradigm shift - Building a new talent management model to boost growthParadigm shift - Building a new talent management model to boost growth
Paradigm shift - Building a new talent management model to boost growthEY
 
Accenture Presentation of HRM
Accenture Presentation of HRMAccenture Presentation of HRM
Accenture Presentation of HRMMimansha Bahadur
 
How to attract the right people
How to attract the right peopleHow to attract the right people
How to attract the right peopleTuấn Hàn
 
Hay guide chart.pptx [autosaved]
Hay guide chart.pptx [autosaved]Hay guide chart.pptx [autosaved]
Hay guide chart.pptx [autosaved]Shivam Srivastava
 
The Power of Gamification in HR
The Power of Gamification in HRThe Power of Gamification in HR
The Power of Gamification in HRSilvia Galessi
 
Talent Management Practices of TCS
Talent Management Practices of TCSTalent Management Practices of TCS
Talent Management Practices of TCSRoopasree Egala
 
Sales Competency Frameworks
Sales Competency FrameworksSales Competency Frameworks
Sales Competency Frameworkssemmy831
 
Recruitment selection process
Recruitment selection processRecruitment selection process
Recruitment selection processazfar
 
Basic principles of mentoring
Basic principles of mentoringBasic principles of mentoring
Basic principles of mentoringNwakerendu Ike
 
Employee Rewards and Recognition
Employee Rewards and RecognitionEmployee Rewards and Recognition
Employee Rewards and RecognitionMary Ward
 
coaching and mentoring
coaching and mentoringcoaching and mentoring
coaching and mentoringNeenu Babu
 
360 Degree Performance Appraisal
360 Degree Performance Appraisal360 Degree Performance Appraisal
360 Degree Performance AppraisalNaresHusys
 
Job Analysis_Evaluation_Grading_Process and Tools
Job Analysis_Evaluation_Grading_Process and ToolsJob Analysis_Evaluation_Grading_Process and Tools
Job Analysis_Evaluation_Grading_Process and ToolsCharles Cotter, PhD
 
Job satisfaction
Job satisfactionJob satisfaction
Job satisfactionvarunsuriya
 
Human Resources Performance Management Metrics PowerPoint Presentation Slides
Human Resources Performance Management Metrics PowerPoint Presentation Slides Human Resources Performance Management Metrics PowerPoint Presentation Slides
Human Resources Performance Management Metrics PowerPoint Presentation Slides SlideTeam
 

What's hot (20)

Role of a trainer ppt @ bec doms mba
Role of a trainer ppt @ bec doms mbaRole of a trainer ppt @ bec doms mba
Role of a trainer ppt @ bec doms mba
 
Paradigm shift - Building a new talent management model to boost growth
Paradigm shift - Building a new talent management model to boost growthParadigm shift - Building a new talent management model to boost growth
Paradigm shift - Building a new talent management model to boost growth
 
Accenture Presentation of HRM
Accenture Presentation of HRMAccenture Presentation of HRM
Accenture Presentation of HRM
 
Employee Engagement
Employee Engagement Employee Engagement
Employee Engagement
 
How to attract the right people
How to attract the right peopleHow to attract the right people
How to attract the right people
 
Hay guide chart.pptx [autosaved]
Hay guide chart.pptx [autosaved]Hay guide chart.pptx [autosaved]
Hay guide chart.pptx [autosaved]
 
The Power of Gamification in HR
The Power of Gamification in HRThe Power of Gamification in HR
The Power of Gamification in HR
 
Talent Management Practices of TCS
Talent Management Practices of TCSTalent Management Practices of TCS
Talent Management Practices of TCS
 
Sales Competency Frameworks
Sales Competency FrameworksSales Competency Frameworks
Sales Competency Frameworks
 
Recruitment selection process
Recruitment selection processRecruitment selection process
Recruitment selection process
 
Basic principles of mentoring
Basic principles of mentoringBasic principles of mentoring
Basic principles of mentoring
 
Employee Rewards and Recognition
Employee Rewards and RecognitionEmployee Rewards and Recognition
Employee Rewards and Recognition
 
Reward Management
Reward ManagementReward Management
Reward Management
 
Job Evaluation
Job EvaluationJob Evaluation
Job Evaluation
 
coaching and mentoring
coaching and mentoringcoaching and mentoring
coaching and mentoring
 
360 Degree Performance Appraisal
360 Degree Performance Appraisal360 Degree Performance Appraisal
360 Degree Performance Appraisal
 
Job Analysis_Evaluation_Grading_Process and Tools
Job Analysis_Evaluation_Grading_Process and ToolsJob Analysis_Evaluation_Grading_Process and Tools
Job Analysis_Evaluation_Grading_Process and Tools
 
Job satisfaction
Job satisfactionJob satisfaction
Job satisfaction
 
Rewards and Recognition
Rewards and RecognitionRewards and Recognition
Rewards and Recognition
 
Human Resources Performance Management Metrics PowerPoint Presentation Slides
Human Resources Performance Management Metrics PowerPoint Presentation Slides Human Resources Performance Management Metrics PowerPoint Presentation Slides
Human Resources Performance Management Metrics PowerPoint Presentation Slides
 

Viewers also liked

Canadian Anti-Spam Legislation(CASL) & New Marketing Strategies
Canadian Anti-Spam Legislation(CASL) & New Marketing StrategiesCanadian Anti-Spam Legislation(CASL) & New Marketing Strategies
Canadian Anti-Spam Legislation(CASL) & New Marketing StrategiesDalia Asterbadi
 
핑그래프(Fingra.ph) 모바일 게임 적용 사례
핑그래프(Fingra.ph) 모바일 게임 적용 사례핑그래프(Fingra.ph) 모바일 게임 적용 사례
핑그래프(Fingra.ph) 모바일 게임 적용 사례Fingra.ph
 
NextGen Customer Engagement - An Extension from Dave McClure's Pirate Startup...
NextGen Customer Engagement - An Extension from Dave McClure's Pirate Startup...NextGen Customer Engagement - An Extension from Dave McClure's Pirate Startup...
NextGen Customer Engagement - An Extension from Dave McClure's Pirate Startup...Dalia Asterbadi
 
Final Presentation-KUHN
Final Presentation-KUHNFinal Presentation-KUHN
Final Presentation-KUHNshippensville
 
realSociable - Creating a need and changing sales flow
realSociable - Creating a need and changing sales flowrealSociable - Creating a need and changing sales flow
realSociable - Creating a need and changing sales flowDalia Asterbadi
 
Arputer overview 3413
Arputer overview   3413Arputer overview   3413
Arputer overview 3413arputer
 
핑그래프(Fingra.ph) 모바일 광고 적용 사례
핑그래프(Fingra.ph) 모바일 광고 적용 사례핑그래프(Fingra.ph) 모바일 광고 적용 사례
핑그래프(Fingra.ph) 모바일 광고 적용 사례Fingra.ph
 

Viewers also liked (8)

Canadian Anti-Spam Legislation(CASL) & New Marketing Strategies
Canadian Anti-Spam Legislation(CASL) & New Marketing StrategiesCanadian Anti-Spam Legislation(CASL) & New Marketing Strategies
Canadian Anti-Spam Legislation(CASL) & New Marketing Strategies
 
Regex lecture
Regex lectureRegex lecture
Regex lecture
 
핑그래프(Fingra.ph) 모바일 게임 적용 사례
핑그래프(Fingra.ph) 모바일 게임 적용 사례핑그래프(Fingra.ph) 모바일 게임 적용 사례
핑그래프(Fingra.ph) 모바일 게임 적용 사례
 
NextGen Customer Engagement - An Extension from Dave McClure's Pirate Startup...
NextGen Customer Engagement - An Extension from Dave McClure's Pirate Startup...NextGen Customer Engagement - An Extension from Dave McClure's Pirate Startup...
NextGen Customer Engagement - An Extension from Dave McClure's Pirate Startup...
 
Final Presentation-KUHN
Final Presentation-KUHNFinal Presentation-KUHN
Final Presentation-KUHN
 
realSociable - Creating a need and changing sales flow
realSociable - Creating a need and changing sales flowrealSociable - Creating a need and changing sales flow
realSociable - Creating a need and changing sales flow
 
Arputer overview 3413
Arputer overview   3413Arputer overview   3413
Arputer overview 3413
 
핑그래프(Fingra.ph) 모바일 광고 적용 사례
핑그래프(Fingra.ph) 모바일 광고 적용 사례핑그래프(Fingra.ph) 모바일 광고 적용 사례
핑그래프(Fingra.ph) 모바일 광고 적용 사례
 

Recently uploaded

Bit N Build Poland
Bit N Build PolandBit N Build Poland
Bit N Build PolandGDSC PJATK
 
"Journey of Aspiration: Unveiling the Path to Becoming a Technocrat and Entre...
"Journey of Aspiration: Unveiling the Path to Becoming a Technocrat and Entre..."Journey of Aspiration: Unveiling the Path to Becoming a Technocrat and Entre...
"Journey of Aspiration: Unveiling the Path to Becoming a Technocrat and Entre...shaiyuvasv
 
DNA LIGASE BIOTECHNOLOGY BIOLOGY STUDY OF LIFE
DNA LIGASE BIOTECHNOLOGY BIOLOGY STUDY OF LIFEDNA LIGASE BIOTECHNOLOGY BIOLOGY STUDY OF LIFE
DNA LIGASE BIOTECHNOLOGY BIOLOGY STUDY OF LIFEandreiandasan
 
5 Things You Shouldn’t Do at Salesforce World Tour Sydney 2024!
5 Things You Shouldn’t Do at Salesforce World Tour Sydney 2024!5 Things You Shouldn’t Do at Salesforce World Tour Sydney 2024!
5 Things You Shouldn’t Do at Salesforce World Tour Sydney 2024!XfilesPro
 
Introduction to Serverless with AWS Lambda in C#.pptx
Introduction to Serverless with AWS Lambda in C#.pptxIntroduction to Serverless with AWS Lambda in C#.pptx
Introduction to Serverless with AWS Lambda in C#.pptxBrandon Minnick, MBA
 
Z-Wave Fan coil Thermostat Heltun_HE-HT01_User_Manual.pdf
Z-Wave Fan coil Thermostat Heltun_HE-HT01_User_Manual.pdfZ-Wave Fan coil Thermostat Heltun_HE-HT01_User_Manual.pdf
Z-Wave Fan coil Thermostat Heltun_HE-HT01_User_Manual.pdfDomotica daVinci
 
Enhancing SaaS Performance: A Hands-on Workshop for Partners
Enhancing SaaS Performance: A Hands-on Workshop for PartnersEnhancing SaaS Performance: A Hands-on Workshop for Partners
Enhancing SaaS Performance: A Hands-on Workshop for PartnersThousandEyes
 
Bringing nullability into existing code - dammit is not the answer.pptx
Bringing nullability into existing code - dammit is not the answer.pptxBringing nullability into existing code - dammit is not the answer.pptx
Bringing nullability into existing code - dammit is not the answer.pptxMaarten Balliauw
 
Early Tech Adoption: Foolish or Pragmatic? - 17th ISACA South Florida WOW Con...
Early Tech Adoption: Foolish or Pragmatic? - 17th ISACA South Florida WOW Con...Early Tech Adoption: Foolish or Pragmatic? - 17th ISACA South Florida WOW Con...
Early Tech Adoption: Foolish or Pragmatic? - 17th ISACA South Florida WOW Con...Adrian Sanabria
 
Q1 Memory Fabric Forum: SMART CXL Product Lineup
Q1 Memory Fabric Forum: SMART CXL Product LineupQ1 Memory Fabric Forum: SMART CXL Product Lineup
Q1 Memory Fabric Forum: SMART CXL Product LineupMemory Fabric Forum
 
"Running Open-Source LLM models on Kubernetes", Volodymyr Tsap
"Running Open-Source LLM models on Kubernetes",  Volodymyr Tsap"Running Open-Source LLM models on Kubernetes",  Volodymyr Tsap
"Running Open-Source LLM models on Kubernetes", Volodymyr TsapFwdays
 
Enhancing Productivity and Insight A Tour of JDK Tools Progress Beyond Java 17
Enhancing Productivity and Insight  A Tour of JDK Tools Progress Beyond Java 17Enhancing Productivity and Insight  A Tour of JDK Tools Progress Beyond Java 17
Enhancing Productivity and Insight A Tour of JDK Tools Progress Beyond Java 17Ana-Maria Mihalceanu
 
Power of 2024 - WITforce Odyssey.pptx.pdf
Power of 2024 - WITforce Odyssey.pptx.pdfPower of 2024 - WITforce Odyssey.pptx.pdf
Power of 2024 - WITforce Odyssey.pptx.pdfkatalinjordans1
 
21ST CENTURY LITERACY FROM TRADITIONAL TO MODERN
21ST CENTURY LITERACY FROM TRADITIONAL TO MODERN21ST CENTURY LITERACY FROM TRADITIONAL TO MODERN
21ST CENTURY LITERACY FROM TRADITIONAL TO MODERNRonnelBaroc
 
AWS reInvent 2023 recaps from Chicago AWS user group
AWS reInvent 2023 recaps from Chicago AWS user groupAWS reInvent 2023 recaps from Chicago AWS user group
AWS reInvent 2023 recaps from Chicago AWS user groupAWS Chicago
 
Building Products That Think- Bhaskaran Srinivasan & Ashish Gupta
Building Products That Think- Bhaskaran Srinivasan & Ashish GuptaBuilding Products That Think- Bhaskaran Srinivasan & Ashish Gupta
Building Products That Think- Bhaskaran Srinivasan & Ashish GuptaISPMAIndia
 
Zi-Stick UBS Dongle ZIgbee from Aeotec manual
Zi-Stick UBS Dongle ZIgbee from  Aeotec manualZi-Stick UBS Dongle ZIgbee from  Aeotec manual
Zi-Stick UBS Dongle ZIgbee from Aeotec manualDomotica daVinci
 
From eSIMs to iSIMs: It’s Inside the Manufacturing
From eSIMs to iSIMs: It’s Inside the ManufacturingFrom eSIMs to iSIMs: It’s Inside the Manufacturing
From eSIMs to iSIMs: It’s Inside the ManufacturingSoracom Global, Inc.
 
Tete thermostatique Zigbee MOES BRT-100 V2.pdf
Tete thermostatique Zigbee MOES BRT-100 V2.pdfTete thermostatique Zigbee MOES BRT-100 V2.pdf
Tete thermostatique Zigbee MOES BRT-100 V2.pdfDomotica daVinci
 
My sample product research idea for you!
My sample product research idea for you!My sample product research idea for you!
My sample product research idea for you!KivenRaySarsaba
 

Recently uploaded (20)

Bit N Build Poland
Bit N Build PolandBit N Build Poland
Bit N Build Poland
 
"Journey of Aspiration: Unveiling the Path to Becoming a Technocrat and Entre...
"Journey of Aspiration: Unveiling the Path to Becoming a Technocrat and Entre..."Journey of Aspiration: Unveiling the Path to Becoming a Technocrat and Entre...
"Journey of Aspiration: Unveiling the Path to Becoming a Technocrat and Entre...
 
DNA LIGASE BIOTECHNOLOGY BIOLOGY STUDY OF LIFE
DNA LIGASE BIOTECHNOLOGY BIOLOGY STUDY OF LIFEDNA LIGASE BIOTECHNOLOGY BIOLOGY STUDY OF LIFE
DNA LIGASE BIOTECHNOLOGY BIOLOGY STUDY OF LIFE
 
5 Things You Shouldn’t Do at Salesforce World Tour Sydney 2024!
5 Things You Shouldn’t Do at Salesforce World Tour Sydney 2024!5 Things You Shouldn’t Do at Salesforce World Tour Sydney 2024!
5 Things You Shouldn’t Do at Salesforce World Tour Sydney 2024!
 
Introduction to Serverless with AWS Lambda in C#.pptx
Introduction to Serverless with AWS Lambda in C#.pptxIntroduction to Serverless with AWS Lambda in C#.pptx
Introduction to Serverless with AWS Lambda in C#.pptx
 
Z-Wave Fan coil Thermostat Heltun_HE-HT01_User_Manual.pdf
Z-Wave Fan coil Thermostat Heltun_HE-HT01_User_Manual.pdfZ-Wave Fan coil Thermostat Heltun_HE-HT01_User_Manual.pdf
Z-Wave Fan coil Thermostat Heltun_HE-HT01_User_Manual.pdf
 
Enhancing SaaS Performance: A Hands-on Workshop for Partners
Enhancing SaaS Performance: A Hands-on Workshop for PartnersEnhancing SaaS Performance: A Hands-on Workshop for Partners
Enhancing SaaS Performance: A Hands-on Workshop for Partners
 
Bringing nullability into existing code - dammit is not the answer.pptx
Bringing nullability into existing code - dammit is not the answer.pptxBringing nullability into existing code - dammit is not the answer.pptx
Bringing nullability into existing code - dammit is not the answer.pptx
 
Early Tech Adoption: Foolish or Pragmatic? - 17th ISACA South Florida WOW Con...
Early Tech Adoption: Foolish or Pragmatic? - 17th ISACA South Florida WOW Con...Early Tech Adoption: Foolish or Pragmatic? - 17th ISACA South Florida WOW Con...
Early Tech Adoption: Foolish or Pragmatic? - 17th ISACA South Florida WOW Con...
 
Q1 Memory Fabric Forum: SMART CXL Product Lineup
Q1 Memory Fabric Forum: SMART CXL Product LineupQ1 Memory Fabric Forum: SMART CXL Product Lineup
Q1 Memory Fabric Forum: SMART CXL Product Lineup
 
"Running Open-Source LLM models on Kubernetes", Volodymyr Tsap
"Running Open-Source LLM models on Kubernetes",  Volodymyr Tsap"Running Open-Source LLM models on Kubernetes",  Volodymyr Tsap
"Running Open-Source LLM models on Kubernetes", Volodymyr Tsap
 
Enhancing Productivity and Insight A Tour of JDK Tools Progress Beyond Java 17
Enhancing Productivity and Insight  A Tour of JDK Tools Progress Beyond Java 17Enhancing Productivity and Insight  A Tour of JDK Tools Progress Beyond Java 17
Enhancing Productivity and Insight A Tour of JDK Tools Progress Beyond Java 17
 
Power of 2024 - WITforce Odyssey.pptx.pdf
Power of 2024 - WITforce Odyssey.pptx.pdfPower of 2024 - WITforce Odyssey.pptx.pdf
Power of 2024 - WITforce Odyssey.pptx.pdf
 
21ST CENTURY LITERACY FROM TRADITIONAL TO MODERN
21ST CENTURY LITERACY FROM TRADITIONAL TO MODERN21ST CENTURY LITERACY FROM TRADITIONAL TO MODERN
21ST CENTURY LITERACY FROM TRADITIONAL TO MODERN
 
AWS reInvent 2023 recaps from Chicago AWS user group
AWS reInvent 2023 recaps from Chicago AWS user groupAWS reInvent 2023 recaps from Chicago AWS user group
AWS reInvent 2023 recaps from Chicago AWS user group
 
Building Products That Think- Bhaskaran Srinivasan & Ashish Gupta
Building Products That Think- Bhaskaran Srinivasan & Ashish GuptaBuilding Products That Think- Bhaskaran Srinivasan & Ashish Gupta
Building Products That Think- Bhaskaran Srinivasan & Ashish Gupta
 
Zi-Stick UBS Dongle ZIgbee from Aeotec manual
Zi-Stick UBS Dongle ZIgbee from  Aeotec manualZi-Stick UBS Dongle ZIgbee from  Aeotec manual
Zi-Stick UBS Dongle ZIgbee from Aeotec manual
 
From eSIMs to iSIMs: It’s Inside the Manufacturing
From eSIMs to iSIMs: It’s Inside the ManufacturingFrom eSIMs to iSIMs: It’s Inside the Manufacturing
From eSIMs to iSIMs: It’s Inside the Manufacturing
 
Tete thermostatique Zigbee MOES BRT-100 V2.pdf
Tete thermostatique Zigbee MOES BRT-100 V2.pdfTete thermostatique Zigbee MOES BRT-100 V2.pdf
Tete thermostatique Zigbee MOES BRT-100 V2.pdf
 
My sample product research idea for you!
My sample product research idea for you!My sample product research idea for you!
My sample product research idea for you!
 

Design Pattern with Burger

  • 4. Public Burger orderBurger(){ Burger burger = new Burger(); burger.prepare(); burger.bake(); burger.filling(); burger.presentation(); Our store can take and give the order. This is the simple way for our function to take order based of strategy in previous slide return burger; }
  • 5. But our store just have one kind of Burger! We have to create 4 menu!
  • 6. Public Burger orderBurger(String type){ Burger burger; if(type == “cheese”){ burger = new CheeseBurger(); } else if(type == “double cheese”){ burger = new DoubleCheeseBurger(); } else if(type == “beef”){ burger = new BeefBurger(); } else if(type == “doublebeef”){ burger = new DoubleBeefBurger(); } That it! Our store can take 4 kind of Burger. - Cheese Burger - Double Cheese Burger - Beef Burger - Double Beef Burger burger.prepare(); burger.bake(); burger.filling(); burger.presentation(); return burger; }
  • 7. But! What about we add new burger and remove old Burger?
  • 8. Public Burger orderBurger(String type){ Burger burger; if(type == “cheese”){ burger = new CheeseBurger(); } else if(type == “double cheese”){ burger = new DoubleCheeseBurger(); } else if(type == “beef”){ burger = new BeefBurger(); } else if(type == “doublebeef”){ burger = new DoubleBeefBurger(); } else if(type == “chesse&beef”){ burger = new CheeseBeefBurger(); } It mess our order burger method and make order burger closed modification burger.prepare(); burger.bake(); burger.filling(); burger.presentation(); return burger; }
  • 9. SOLUTION! -> simple factory Make simple factory that can produce one kind burger. Public class BurgerStore{ BurgerFactory factory; Public BurgerStore(BurgerFactory factory){ this.factory = factory; } Public Burger orderBurger(String type){ Burger burger = factory.createBurger(type); burger.prepare(); burger.bake(); burger.filling(); burger.presentation(); Public class BurgerFactory{ return burger; Public Burger createBurger(String type){ Burger burger; if(type == “cheese”){ burger = new CheeseBurger(); } else if(type == “beef”){ burger = new BeefBurger(); } else if(type == “doublebeef”){ burger = new DoubleBeefBurger(); } else if(type == “chesse&beef”){ burger = new CheeseBeefBurger(); } return burger; } } } }
  • 10. Now, we can sell our Burgers!
  • 11. Oh Look! Our store expands! Now we have 2 store, but have different menu
  • 12. Back to old solution? Because our both store have different menu, we can’t have same factory
  • 13. Add 2 factory - It can be a solution. Each store can choose their own factory. - But if other store share one factory and suddenly add their own menu, it can be a problem later. Public class BurgerFactoryStore1{ Public class BurgerFactoryStore2{ Public Burger createBurger(String type){ Burger burger; Public Burger createBurger(String type){ Burger burger; if(type == “cheese”){ burger = new CheeseBurger(); } else if(type == “beef”){ burger = new BeefBurger(); } else if(type == “doublebeef”){ burger = new DoubleBeefBurger(); } else if(type == “chesse&beef”){ burger = new CheeseBeefBurger(); } if(type == “cheese”){ burger = new CheeseBurger(); } else if(type == “doublecheese”){ burger = new DoubleCheeseBurger(); } else if(type == “beef”){ burger = new BeefBurger(); } else if(type == “doublebeef”){ burger = new DoubleBeefBurger(); } return burger; return burger; } } } }
  • 14. Solution? What about we make every store decide their own menu?
  • 15. SOLUTION! -> factory method Public class Store1 extends BurgerStore{ Public Burger createBurger(String type){ Burger burger; We just make interface for our store, but they can decide their own menu. Public abstract class BurgerStore{ BurgerFactory factory; if(type == “cheese”){ burger = new CheeseBurger(); } else if(type == “beef”){ burger = new BeefBurger(); } return burger; } } Public BurgerStore(BurgerFactory factory){ this.factory = factory; } Public Burger orderBurger(String type){ Burger burger = createBurger(type); Public class Store2 extends BurgerStore{ Public Burger createBurger(String type){ Burger burger; burger.prepare(); burger.bake(); burger.filling(); burger.presentation(); if(type == “beef”){ burger = new BeefBurger(); } else if(type == “doublebeef”){ burger = new DoubleBeefBurger(); } return burger; return burger; } Public abstract Burger createBurger (String type); } } }
  • 16. But we have other problem! Customer want other style of vegetable and beef too.
  • 17. Look our Burger One of our kind of Burger Public abstract class Burger{ Beef factory; Vegetable vegetable; Public abstract void prepare(); Public void bake(){ // some method } Public void filling(){ // some method } Public class ChesseBburger extends Burger{ Public void ChesseBburger(// need ingredient){ Public void presentation(){ // some method } } } Public void prepare(){}; }
  • 18. This our ingredient creator Public interface IngredientFactory { Need ingredient factory that create beef and vegetable Public class IndonesianBurgerIngredientFactory { Public Beef createBeef(); Public Vegetable createVegetable(); } Public class JapaneseBurgerIngredientFactory { Public Beef createBeef(){ return new SapiLadaHitam(); } Public Vegetable createVegetable(){ return new Kangkung(); } } Public Beef createBeef(){ return new FreshFish(); } Public Vegetable createVegetable(){ return new Nori(); } }
  • 19. Solution! -> Abstract Factory Method Now we can take ingredient style customer want without affecting our method in burger. Public class ChesseBburger extends Burger{ IngredientFactory ingredient; Public void ChesseBburger( IngredientFactory ingredient){ this.Ingredient = ingredient; } Public void prepare(){ ingredient.createBeef(); ingredient.createVegetable(); }; Public class Store1 extends BurgerStore{ Public Burger createBurger(String type, IngredientFactory ingredient){ Burger burger; if(type == “cheese”){ burger = new CheeseBurger(ingredient); } else if(type == “beef”){ burger = new BeefBurger(ingredient); } return burger; } } }
  • 20. Review Simple factory is a simple way to decouple our client from concrete class.  Factory Method relies on inheritance : object creation is delegated to subclasses which implement the factory method to create object.  Abstract factory Method relies on object composition : ocject creation is implemented in method exposed in factory interface. 
  • 21. Review  All factory pattern promote loose coupling by reducing the depedency on concrete class. Concrete class is class which will be an object concrete.
  • 22. Design Pattern   Is a description or template for how to solve a problem that can be used in many different situations. Design patterns are optimized, reusable solutions to the programming problems that we encounter every day.
  • 23. Design Principle   Take the parts that vary and encapsulate them. So, we can can alter or extend that vary later without affecting those that don’t.
  • 24. Design Principle  Code for an interface, not code for and implementation.
  • 25. Design Principle  Depend upon abstraction, don’t upon concrete class.