CS 350 – Software Design Abstract Factory Pattern – Chapter 11 Provides an interface for creating families of related or dependent objects without specifying.

Slides:



Advertisements
Similar presentations
CS 350 – Software Design The Bridge Pattern – Chapter 10 Most powerful pattern so far. Gang of Four Definition: Decouple an abstraction from its implementation.
Advertisements

COP 3331 Object Oriented Analysis and Design Chapter 7 – Design by Abastraction Jean Muhammad.
The Bridge Pattern.. Intent Decouple an abstraction from its implementation so that the two can vary independently Also known as: Handle/Body.
Inheritance issues SE-2811 Dr. Mark L. Hornick 1.
CS 106 Introduction to Computer Science I 11 / 09 / 2007 Instructor: Michael Eckmann.
Computer Science – Game DesignUC Santa Cruz Today Publish/Subscribe Design Pattern Delegates Sprite movement Particles.
 Consists of Creational patterns  Each generator pattern has a Client, Product, and Generator.  The Generator needs at least one operation that creates.
Iterators T.J. Niglio Computer & Systems Engineering Fall 2003 Software Design & Documentation Object Behavioral.
Satzinger, Jackson, and Burd Object-Orieneted Analysis & Design
CS 4233 : Object-Oriented Analysis and Design Concrete Factory Abstract Factory.
Chapter 8 Object Design Reuse and Patterns. Finding Objects The hardest problems in object-oriented system development are: –Identifying objects –Decomposing.
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
Marcelo Santos – OOAD-CDT309, Spring 2008, IDE-MdH 1 Object-Oriented Analysis and Design - CDT309 Period 4, Spring 2008 Design Patterns: someone has already.
ECE 355 Design Patterns Tutorial Part 2 (based on slides by Ali Razavi) Presented by Igor Ivković
+ Informatics 122 Software Design II Lecture 8 Emily Navarro Duplication of course material for any commercial purpose without the explicit written permission.
The switch Statement, DecimalFormat, and Introduction to Looping
3/15/05H-1 © 2001 T. Horton CS 494 Object-Oriented Analysis & Design Evaluating Class Diagrams Topics include: Cohesion, Coupling Law of Demeter (handout)
CS 4240: Bridge and Abstract Factory Readings:  Chap. 10 and 11 Readings:  Chap. 10 and 11.
CS 210 Introduction to Design Patterns September 28 th, 2006.
Case Studies on Design Patterns Design Refinements Examples.
CS 350 – Software Design An Introduction to Design Patterns – Chapter 5 A proposition behind design patterns is that quality of software systems can be.
CS 350 – Software Design The Object Paradigm – Chapter 1 If you were tasked to write code to access a description of shapes that were stored in a database.
Chapter 1 Program Development Asserting Java © Rick Mercer.
CS 4240: More Design Patterns Readings: Chap. 9. Let’s Recap Some Ideas and Strategies We’ll assume some design-planning is useful up-front Design with.
Object Oriented Analysis & Design & UML (Unified Modeling Language)1 Part V: Design The Design Workflow Design Classes Refining Analysis Relationships.
ISP666 MVC & Design Patterns. Outline Review Event Programming Model Model-View-Controller Revisit Simple Calculator Break Design Patterns Exercise.
Design Design and Software Architecture. The design phase The analysis phase describes what the system should be doing The design phase describes how.
Sayed Ahmed Computer Engineering, BUET, Bangladesh Masters from the University of Manitoba, Canada
Y2 eProjects Session 4 – Advanced Topics. Objectives  Dynamic Models  Design Patterns (Optional)  Software testing (for S4) ACCP i7.1\Sem3_4\eProject\T4.
Chapter 2 Introducing Interfaces Summary prepared by Kirk Scott.
CS 350 – Software Design The Strategy Pattern – Chapter 9 Changes to software, like other things in life, often focus on the immediate concerns and ignore.
Unit 4 Object-Oriented Design Patterns NameStudent Number CAI XIANGHT082182A KYAW THU LINHT082238Y LI PENGFEIHT082220L NAUNG NAUNG LATTHT082195L PLATHOTTAM.
Incremental Design Why incremental design? Goal of incremental design Tools for incremental design  UML diagrams  Design principles  Design patterns.
Define an interface for creating an object, but let subclasses decide which class to instantiate Factory Method Pattern.
CS 4233 Review Feb February Review2 Outline  Previous Business – My.wpi.edu contains all grades to date for course – Review and contact.
Define an interface for creating an object, but let subclasses decide which class to instantiate.
CS 350 – Software Design Expanding Our Horizons – Chapter 8 The traditional view of objects is that they are data with methods. Sometimes objects could.
CS212: Object Oriented Analysis and Design Lecture 38: Design Pattern-II.
Design Patterns Introduction
CS 210 Iterator Pattern October 31 st, Example to motivate discussion We have two lists (of menu items) one implemented using ArrayList and another.
Example to motivate discussion We have two lists (of menu items) one implemented using ArrayList and another using Arrays. How does one work with these.
Proxy Pattern defined The Proxy Pattern provides a surrogate or placeholder for another object to control access to it by creating a representative object.
CS 210 Proxy Pattern Nov 16 th, RMI – A quick review A simple, easy to understand tutorial is located here:
Systems Requirements SE 3821 Design? Algorithms CS 2852.
CS 210 Introduction to OO Design August 24, 2006
Chapter Ten The Bridge Pattern Ku-Yaw Chang Assistant Professor, Department of Computer Science and Information Engineering Da-Yeh.
CS 350 – Software Design The Adapter Pattern – Chapter 7 Gang of Four Definition: Convert the interface of a class into another interface that the client.
Design and implementation Chapter 7 – Lecture 1. Design and implementation Software design and implementation is the stage in the software engineering.
CS, AUHenrik Bærbak Christensen1 Compositional Design Principles The “GoF” principles Or Principles of Flexible Design.
Duke CPS Programming Heuristics l Identify the aspects of your application that vary and separate them from what stays the same ä Take what varies.
Deriving Abstract Factory Loosening the coupling when creating objects...
Further Abstraction Techniques Chapter 10. Abstract Classes There are times when you do not want someone to be able to make an object of your class. For.
1 BUILDING JAVA PROGRAMS CHAPTER 2 PRIMITIVE DATA AND DEFINITE LOOPS.
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.
3/1/01H-1 © 2001 T. Horton CS 494 Object-Oriented Analysis & Design Evaluating Class Diagrams Topics include: Cohesion, Coupling Law of Demeter (handout)
1 Welcome Alireza Humber College Lecture 1 Game 540 Alireza
Low Budget Productions, LLC
CS 350 – Software Design The Strategy Pattern – Chapter 9
Chapter Nine The Strategy Pattern
Copyright © by Curt Hill
Presented by Igor Ivković
SE-2811 Software Component Design
Abstract Factory Pattern
CS 350 – Software Design A Standard Object-Oriented Solution – Chapter 4 Before studying design patterns, many programmers solve a problem by starting.
CS 350 – Software Design An Introduction to Design Patterns – Chapter 5 A proposition behind design patterns is that quality of software systems can be.
DESIGN PATTERNS : State Pattern
CS 350 – Software Design Principles and Strategies – Chapter 14
Multiple Inheritance in C++
Presented by Igor Ivković
Presentation transcript:

CS 350 – Software Design Abstract Factory Pattern – Chapter 11 Provides an interface for creating families of related or dependent objects without specifying their concrete classes. Imagine you had a computer system with a High and low resolution display driver as well as a high and low resolution print driver. For DriverIn a Low Capacity MachineIn a High Capacity Machine DisplayLRDDHRDD Low Resolution Display DriverHigh Resolution Display Driver PrintLRPDHRPD Low Resolution Print DriverHigh Resolution Print Driver While in this case the items are mutually exclusive, this is not always the case. A mid-range computer system might use a LRDD and a HRPD.

CS 350 – Software Design Abstract Factory Pattern – Chapter 11 A simple solution is to use switch statements as in the following code: //JAVA CODE FRAGMENT Class ApControl { public void doDraw() { public void doDraw() { switch (RESOLUTION) { switch (RESOLUTION) { case LOW: case LOW: //use LRDD case HIGH: case HIGH: //use HRDD } } public void doPrint() { public void doPrint() { switch (RESOLUTION) { switch (RESOLUTION) { case LOW: case LOW: //use LRPD case HIGH: case HIGH: //use HRPD } }} Why is this bad? Obviously I have said switch statements are not good, but that’s the superficial answer. The problem is that the code has to decide over and over again and in multiple places what driver it has to use. This leads to tight coupling and weak cohesion.

CS 350 – Software Design Abstract Factory Pattern – Chapter 11 Let’s apply inheritance to the problem by having two different ap controllers.

CS 350 – Software Design Abstract Factory Pattern – Chapter 11 What’s wrong with the previous approach? Combinatorial explosion. Instead as we said before, it is better to favor aggregation. Instead, let’s have two classes with inheritance.

CS 350 – Software Design Abstract Factory Pattern – Chapter 11 Ap controller now can use the two classes and not have to perform switches to determine which driver to use.

CS 350 – Software Design Abstract Factory Pattern – Chapter 11 The improved Ap controller code follows: //JAVA CODE FRAGMENT Class ApControl { public void doDraw() { public void doDraw() { myDisplayDriver.draw(); myDisplayDriver.draw(); } public void doPrint() { public void doPrint() { myPrintDrive.draw(); myPrintDrive.draw(); }}