ANU COMP2110 Software Design in 2004 Lecture 17Slide 1 COMP2110 in 2004 Software Design Lecture 17: Software design patterns (4) 1The Abstract Factory.

Slides:



Advertisements
Similar presentations
Creational Patterns, Abstract Factory, Builder Billy Bennett June 11, 2009.
Advertisements

CSE3308/CSC Software Engineering: Analysis and DesignLecture 5B.1 Software Engineering: Analysis and Design - CSE3308 Patterns CSE3308/CSC3080/DMS/2000/12.
Design Patterns Copyright © Vyacheslav Mukhortov, Nikita Nyanchuk-Tatarskiy, Copyright © INTEKS LLC,
Plab – Tirgul 12 Design Patterns
Patterns Reusable solutions to common object-oriented programming problems When given a programming problem, re-use an existing solution. Gang of Four.
Dept. of Computer Engineering, Amirkabir University of Tech. 1 Design Patterns Dr. Noorhosseini Introduction.
CSE Software Engineering: Analysis and Design, 2002Lecture 7B.1 Software Engineering: Analysis and Design - CSE3308 Patterns CSE3308/DMS/2002/15.
Design Patterns CS is not simply about programming
Design Patterns. What are design patterns? A general reusable solution to a commonly occurring problem. A description or template for how to solve a problem.
Creational Patterns: The Abstract Factory CSE 335 Spring 2008 E. Kraemer.
Design Patterns Module Name - Object Oriented Modeling By Archana Munnangi S R Kumar Utkarsh Batwal ( ) ( ) ( )
ECE 355 Design Patterns Tutorial Part 2 (based on slides by Ali Razavi) Presented by Igor Ivković
Design Patterns academy.zariba.com 1. Lecture Content 1.What are Design Patterns? 2.Creational 3.Structural 4.Behavioral 5.Architectural 6.Design Patterns.
Design Patterns Ric Holt & Sarah Nadi U Waterloo, March 2010.
Linzhang Wang Dept. of Computer Sci&Tech, Nanjing University The Abstract Factory Pattern.
Pattern Abstract Factory
Creational Patterns Making Objects The Smart Way Brent Ramerth Abstract Factory, Builder.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. The Factory Method Design Pattern (1) –A creational design.
Vrije Universiteit amsterdamPostacademische Cursus Informatie Technologie Idioms and Patterns polymorphism -- inheritance and delegation idioms -- realizing.
Design Patterns.
Software Waterfall Life Cycle Requirements Construction Design Testing Delivery and Installation Operations and Maintenance Concept Exploration Prototype.
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.
SOEN 6011 Software Engineering Processes Section SS Fall 2007 Dr Greg Butler
Software Components Creational Patterns.
SOEN 343 Software Design Section H Fall 2006 Dr Greg Butler
 How are you going to collaborate?  How are you going to divide up work?  How are you going to make sure that changes work with other people’s code?
L11-12: Design Patterns Definition Iterator (L4: Inheritance)‏ Factory (L4: Inheritance)‏ Strategy (L5: Multiple Inheritance)‏ Composite (L6: Implementation.
Excellence is a Habit Feb Lecture 14 We are what we repeatedly do. Excellence, then, is not an act, but a habit.” - Aristotle.
CDP-1 9. Creational Pattern. CDP-2 Creational Patterns Abstracts instantiation process Makes system independent of how its objects are –created –composed.
Introduction to Design Patterns. Questions What is a design pattern? Who needs design patterns? How different are classes and objects in APL compared.
Creational Patterns
SWE 316: Software Design and Architecture – Dr. Khalid Aljasser Objectives Lecture 13 Creational Design Pattern SWE 316: Software Design and Architecture.
DESIGN PATTERNS Sanjeeb Kumar Nanda 30-Aug What is a pattern? Pattern is a recurring solution to a standard problem Each Pattern describes a problem.
FACTORY METHOD. Design Pattern Space Purpose ScopeCreationalStructuralBehavioral ClassFactory MethodAdapterInterpreter Template Method ObjectAbstract.
CS616: Software Engineering Spring 2009 Design Patterns Sami Taha.
Software Design Patterns Curtsy: Fahad Hassan (TxLabs)
Billy Bennett June 22,  Intent Specify the kinds of objects to create using a prototypical instance, and create new objects by copying this prototype.
CS212: Object Oriented Analysis and Design Lecture 38: Design Pattern-II.
Advanced Object-oriented Design Patterns Creational Design Patterns.
CSC 480 Software Engineering Lab 5 – Abstract Factory Pattern Oct 30, 2002.
Chapter 8 Object Design Reuse and Patterns. More Patterns Abstract Factory: Provide manufacturer independence Builder: Hide a complex creation process.
CS 5150 Software Engineering Lecture 16 Program Design 3.
 Creational design patterns abstract the instantiation process.  make a system independent of how its objects are created, composed, and represented.
The Abstract Factory Pattern (Creational) ©SoftMoore ConsultingSlide 1.
S.Ducasse Stéphane Ducasse 1 Abstract Factory.
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.
Abstract Factory pattern Intent Provide an interface for creating families of related or dependent objects without specifying their concrete classes.
Design Patterns CSCE 315 – Programming Studio Spring 2013.
Abstract Factory Pattern
Design Patterns Lecture part 2.
Factory Patterns 1.
Introduction to Design Patterns
WARNING These slides are not optimized for printing or exam preparation. These are for lecture delivery only. These slides are made for PowerPoint 2010.
object oriented Principles of software design
WARNING These slides are not optimized for printing or exam preparation. These are for lecture delivery only. These slides are made for PowerPoint 2010.
Abstract Factory Pattern
SOEN 343 Software Design Computer Science and Software Engineering Department Concordia University Fall 2005 Instructor: Patrice Chalin.
WARNING These slides are not optimized for printing or exam preparation. These are for lecture delivery only. These slides are made for PowerPoint 2010.
Intent (Thanks to Jim Fawcett for the slides)
Presented by Igor Ivković
Design Patterns - A few examples
Software Engineering Lecture 7 - Design Patterns
Design Patterns in Game Design
Informatics 122 Software Design II
Object Oriented Design Patterns - Creational Patterns
Ms Munawar Khatoon IV Year I Sem Computer Science Engineering
Informatics 122 Software Design II
Presented by Igor Ivković
Presentation transcript:

ANU COMP2110 Software Design in 2004 Lecture 17Slide 1 COMP2110 in 2004 Software Design Lecture 17: Software design patterns (4) 1The Abstract Factory pattern 2Adapter pattern

ANU COMP2110 Software Design in 2004 Lecture 17Slide 2 Abstract Factory (1) Abstract Factory is a creational pattern – like these abstract factory factory singleton prototype other types: structural façade, composite, adapter,... behavioral observer, iterator, command, state, visitor,...

ANU COMP2110 Software Design in 2004 Lecture 17Slide 3 Creational patterns Creational patterns are ways of organising the creation of many objects (beyond new, creation, constructor) Factorycreate new objects when the constructor alone is not enough Singletoncreate only one widely shared object with a public accessor method Prototypecreate sets of objects like example objects Abstract Factorycreate families of objects in related groups

ANU COMP2110 Software Design in 2004 Lecture 17Slide 4 Abstract Fcatory - an example [2001 exam] A software system for handling student results has these requirements: 1.There are two classes of students: Arts and Science. Each Faculty will have its own set of records, one for all Arts students, the other for all Science students. 2.A student's record contains an ID number, type of degree, and marks for all subjects taken this semester. 3.Arts students’ records have their major discipline (a string like "History"). 4.Arts students only take Arts subjects; Science students only take Science subjects. 5.Each arts student takes 4 subjects, each science student takes only 3. 6.Every subject has a name and a subject code. 7.Arts subjects have an exam mark and an essay mark, each out of Science subjects have an exam mark out of 100 and two assignment marks 9.Every subject has a final mark that can be computed by a function called final. 10.The same method called grade is used for all subjects for calculating the grade from the final mark.

ANU COMP2110 Software Design in 2004 Lecture 17Slide 5 Students and subjects ArtsStudt major SciStudt exam essay final() exam asg1 asg2 final() ArtsSubjtScienceSubj t Student ID,degree Subject ScienceRecordMaker CreateStudent() CreateSubject() > ArtsRecordMaker CreateStudent() CreateSubject() AbstractRecordMaker CreateStudent() CreateSubject() RM = new ArtsRecordMaker() // or new ScienceRecordMaker() s = RM.CreateStudent() -- includes setNSubjs for sc in [1..s.NSubjs] s.subject[sc]= RM.CreateSubject()

ANU COMP2110 Software Design in 2004 Lecture 17Slide 6 Abstract Factory – the Pattern (GoF p87+) Intent: provide an interface for creating families of related or dependent objects without specifying their concrete classes Applicability: use when a system should be independent of how its products are created, composed, represented a system should be configured with one or more multiple families of products a family of related products is designed to be used together, and you need to enforce this constraint you want to provide a class library of products, and you want to reveal their interfaces, not their implementations

ANU COMP2110 Software Design in 2004 Lecture 17Slide 7 Abstract Factory – the general structure see diagram – Jezequel p. 87

ANU COMP2110 Software Design in 2004 Lecture 17Slide 8 Abstract Factory – the Pattern (GoF p87+) Consequences: isolates concrete classes makes exchanging product families easy (e.g. add a new Faculty – just another ConcreteFactory class like ArtsRecordMaker) promotes consistency among products BUT – supporting new families of products is difficult because the interface fixes the set of products in the family (e.g. [CreateStudent, CreateSubject])

ANU COMP2110 Software Design in 2004 Lecture 17Slide 9 ArtsStudt major SciStudt exam essay final() exam asg1 asg2 final() ArtsSubjtScienceSubj t Student ID,degree Subject ScienceRecordMaker CreateStudent() CreateSubject() ArtsRecordMaker CreateStudent() CreateSubject() AbstractRecordMaker CreateStudent() CreateSubject() Abstract Factory ConcreteFactory1 ConcreteFactory2 Abstract ProductA Abstract ProductB ProductA1 ProductA2 ProductB2 ProductB1

ANU COMP2110 Software Design in 2004 Lecture 17Slide 10 lecture continues... more on Abstract Factory – see separate HTML notes 17.2 abstract-factory.html Adapter – see separate HTML notes 17.3 adapter.html