Brittany Johnson CSCI360 Abstract Factory Design Pattern.

Slides:



Advertisements
Similar presentations
Continuation of chapter 6…. Nested while loop A while loop used within another while loop is called nested while loop. Q. An illustration to generate.
Advertisements

Creational Patterns, Abstract Factory, Builder Billy Bennett June 11, 2009.
Chapter 4: The Factory Pattern. Consider the Following Code Fragment Duck duck; if (picnic) { duck = new MallardDuck(); } else if (hunting) { duck = new.
Design Patterns A General reusable solution to a commonly occurring problem in software design. Creational: Deal with object creation mechanisms – Example:
 Consists of Creational patterns  Each generator pattern has a Client, Product, and Generator.  The Generator needs at least one operation that creates.
Informatics 122 Software Design II Lecture 5 Emily Navarro Duplication of course material for any commercial purpose without the explicit written permission.
Feb Ron McFadyen1 Factory Method Iterator Example : Java collection classes represent an example of the Factory Method design pattern. The.
March Ron McFadyen1 Singleton pattern Singleton is designed to restrict instantiation of a class to one (or a few) objects. Useful when exactly.
Java Review 2. The Agenda The following topics were highlighted to me as issues: –File IO (Rem) –Wrappers (Rem) –Interfaces (Rem) –Asymptotic Notation.
+ Informatics 122 Software Design II Lecture 8 Emily Navarro Duplication of course material for any commercial purpose without the explicit written permission.
Creational Patterns Making Objects The Smart Way Brent Ramerth Abstract Factory, Builder.
Ingredients on a Pizza What do you like on your pizza? Extended Activity PPT41.
Design Patterns.
Case Studies on Design Patterns Design Refinements Examples.
CS 350 – Software Design Template Method Pattern Let’s look at two objects public class Coffee { public void prepareRecipe() { public void prepareRecipe()
An Introduction to Design Patterns. Introduction Promote reuse. Use the experiences of software developers. A shared library/lingo used by developers.
Abstract Factory Design Pattern making abstract things.
Factory Method A Creational Design Pattern. Factory Method Key Features  Defines an interface for creating objects without needing to know each object’s.
Software Engineering 1 Object-oriented Analysis and Design Applying UML and Patterns An Introduction to Object-oriented Analysis and Design and Iterative.
Tech Talk Go4 Factory Patterns Presented By: Matt Wilson.
BUILDER, MEDIATOR, AND DECORATOR Team 2 (Eli.SE).
Abstract Factory Abstract Factory using Factory Method.
Mohammed Al-Dhelaan CSci 253 Object Oriented Design Instructor: Brad Taylor 06/02/2009 Factory Method Pattern.
By James Sheets. An object creational pattern. Separates the construction of a complex object from its representation so that the same construction process.
CS 210 Review Session October 5 th, Head First Design Patterns Chapter 4 Factory Pattern.
Define an interface for creating an object, but let subclasses decide which class to instantiate Factory Method Pattern.
Csci 490 / Engr 596 Special Topics / Special Projects Software Design and Scala Programming Spring Semester 2010 Lecture Notes.
Factory Method Explained. Intent  Define an interface for creating an object, but let subclasses decide which class to instantiate.  Factory Method.
Define an interface for creating an object, but let subclasses decide which class to instantiate.
Creational Pattern: Factory Method At times, a framework is needed to standardize the behavior of objects that are used in a range of applications, while.
Design Patterns Yonglei Tao. Design Patterns  A design pattern describes a recurring design problem, a solution, and the context in which that solution.
CSC 480 Software Engineering Design With Patterns.
Programmeerimine Delphi keskkonnas MTAT Programmeerimine Delphi keskkonnas MTAT Jelena Zaitseva
FacadeDesign Pattern Provide a unified interface to a set of interfaces in a subsystem. Defines a high level interface that makes the subsystem easier.
DESIGN PATTERNS COMMONLY USED PATTERNS What is a design pattern ? Defining certain rules to tackle a particular kind of problem in software development.
CS 415 N-Tier Application Development By Umair Ashraf June 22,2013 National University of Computer and Emerging Sciences Lecture # 3 Design Patterns (Observer,Factory,Singleton)
Design Patterns Introduction
State Design Pattern. Behavioral Pattern Allows object to alter its behavior when internal state changes Uses Polymorphism to define different behaviors.
The Factory Pattern Sanjay Yadav (ISE ).
CSC 480 Software Engineering Design With Patterns.
CSC 480 Software Engineering Lab 5 – Abstract Factory Pattern Oct 30, 2002.
Singleton Pattern Presented By:- Navaneet Kumar ise
1 More OO Design Patterns CSC 335: Object-Oriented Programming and Design.
Pat’s Pizza creation Pizza orderPizza(String type){ Pizza pizza; if (type.equals(“cheese”)) { pizza = new CheesePizza(); } else if type.equals(“greek”))
 Creational design patterns abstract the instantiation process.  make a system independent of how its objects are created, composed, and represented.
Façade Design Pattern by Ali Alkhafaji Unified interface for a set of interfaces to promote readability and usability.
CS 350 – Software Design The Decorator Pattern – Chapter 17 In this chapter we expand our e-commerce case study and learn how to use the Decorator Pattern.
Csci 490 / Engr 596 Special Topics / Special Projects Software Design and Scala Programming Spring Semester 2010 Lecture Notes.
Design Patterns Creational Patterns. Abstract the instantiation process Help make the system independent of how its objects are created, composed and.
Abstract Factory Pattern Jiaxin Wang CSPP Winter 2010.
SE 461 Software Patterns. ABSTRACT FACTORY PATTERN.
SE 461 Software Patterns. FACTORY METHOD PATTERN.
Design Patterns: MORE Examples
Object-Orientated Analysis, Design and Programming
Design Patterns: Brief Examples
Design Pattern Catalogues
Low Budget Productions, LLC
Factory Patterns 1.
Design Patterns - A few examples
Programming Design Patterns
Software Engineering Lecture 7 - Design Patterns
Abstract Factory Pattern
Behavioral Design Pattern
Ms Munawar Khatoon IV Year I Sem Computer Science Engineering
class PrintOnetoTen { public static void main(String args[]) {
Software Design Lecture : 39.
CSC 480 Software Engineering
Software Design Lecture : 28.
State Design Pattern.
Presentation transcript:

Brittany Johnson CSCI360 Abstract Factory Design Pattern

Name: Abstract Factory Nickname: Kit or Toolkit What is it? A Creational software design pattern; similar to the Factory Method pattern. What does it do? It provides a way of encapsulating individual factories into a group with a common theme. Background

Benefits:  low coupling  ease of changeability  promotes consistency Downfall:  difficult to support new kinds of products Consequences

UML Diagram

public interface PizzaIngredientFactory { Dough createDough(); Sauce createSauce(); Cheese createCheese(); } public class NYPizzaIngredientFactory implements PizzaIngredientFactory { public NYPizzaIngredientFactory(){ } public Cheese createCheese(){ return new ReggianoCheese(); } public Dough createDough(){ return new ThinCrustDough(); } public Sauce createSauce(){ return new MarinaraSauce(); } public Veggies [] createVeggies(){ Veggies veggies [] = {new Olives(), new GreenPeppers() }; return veggies; } public Pepperoni createPepperoni(){ return new ThinPepperoni(); } Abstract Factory & Factory

public class NYPizza extends Pizza{ public NYPizza(){ } public void prepare(String PizzaType){ NYPizzaIngredientFactory NYP = new NYPizzaIngredientFactory(); NYP.createCheese(); NYP.createDough(); NYP.createPepperoni(); NYP.createSauce(); NYP.createVeggies(); } public static void main(String[] args) { System.out.println("What kind of Pizza would you like? Press NY for New York style and C for Chicago style."); String pType = ""; BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); try { pType = in.readLine(); if (pType.equals("NY")){ NYPizza nyPizza = new NYPizza(); nyPizza.prepare(pType); System.out.println("Your New York Style Pizza has been created."); } } Subclass and Client