SOEN 343 Software Design Computer Science and Software Engineering Department Concordia University Fall 2005 Instructor: Patrice Chalin.

Slides:



Advertisements
Similar presentations
Chapter 5: The Singleton Pattern
Advertisements

Design Patterns based on book of Gang of Four (GoF) Erich Gamma, Richard Helm, Ralph Johnson, and John VlissidesGang of Four (GoF) Elements of Reusable.
Object-Oriented Analysis and Design
Visibility Larman, Chapter 19 (with ideas from George Blank of NJIT) CSE432 Object Oriented Software Engineering.
SOEN 343 Software Design Section H Fall 2006 Dr Greg Butler
© Keith Vander Linden, Dilbert © United Feature Syndicate, Inc.
SOEN 343 Software Design Section H Fall 2006 Dr Greg Butler
Jan Ron McFadyen1 Singleton To guarantee that there is at most one instance of a class we can apply the singleton pattern. Singleton Static.
Nov R McFadyen1 Design Patterns (GoF) contains the creational patterns: Abstract factory Builder Factory method (section 23.3 has a Simple.
March R McFadyen1 Design Patterns (GoF) contains the creational patterns: Abstract factory Builder Factory method (in Larman) Prototype Singleton.
NJIT More GRASP Patterns Chapter 22 Applying UML and Patterns Craig Larman Prepared By: Krishnendu Banerjee.
Fall 2009ACS-3913 Ron McFadyen1 idea was first put forth by Christopher Alexander (1977) in his work on architectural design principles a pattern is a.
March R McFadyen1 GoF (Gang of Four): Gamma, Johnson, Helm & Vlissides Book: Design Patterns: Elements of Reusable Object-Oriented Software.
Fall 2009ACS-3913 R McFadyen1 Singleton Problem: Exactly one instance of a certain object is required (this object is called a singleton). We must ensure.
Design Patterns Ref : Chapter 15 Bennett et al. useful groups of collaborating classes that provide a solution to commonly occuring problems. provide.
Chapter 26 Applying Gang of Four Design Patterns 1CS6359 Fall 2012 John Cole.
Chapter 7 GRASP patterns Dr Seham Mostefai CAP 252.
GRASP Principles. How to Design Objects The hard step: moving from analysis to design How to do it? –Design principles (Larman: “patterns”) – an attempt.
Patterns 1 Patterns in OO - history 77 - Work of the architect Christopher Alexander 80s - Kent Beck playing with Smalltalk 91 - Gamma’s PhD thesis on.
1 Chapter 17 GRASP Design Patterns: Designing Objects with Responsibilities.
CSSE 374: Introduction to Gang of Four Design Patterns
1 SAD2 - UML 4 th Lecture Class Diagram in Construction Phase Patterns Case Study Lecturer: Dr Dimitrios Makris
SOEN 6011 Software Engineering Processes Section SS Fall 2007 Dr Greg Butler
Software Engineering 1 Object-oriented Analysis and Design Applying UML and Patterns An Introduction to Object-oriented Analysis and Design and Iterative.
SOEN 6011 Software Engineering Processes Section SS Fall 2007 Dr Greg Butler
BTS430 Systems Analysis and Design using UML Design Patterns.
CS 325: Software Engineering February 12, 2015 Applying Responsibility-Assignment Patterns Design Patterns Situation-Specific Patterns Responsibility-Assignment.
GoF Design Patterns (Ch. 26). GoF Design Patterns Adapter Factory Singleton Strategy Composite Façade Observer (Publish-Subscribe)
CPSC 372 John D. McGregor Module 4 Session 1 Design Patterns.
CS 160: Software Engineering October 22 Class Meeting Department of Computer Science San Jose State University Fall 2014 Instructor: Ron Mak
Gang of Four Patterns 23 total 15 useful How are they different from GRASP Patterns?
Advanced Object-Oriented Design Patterns and Architectures Part One COEN396A John Xiao
CS212: Object Oriented Analysis and Design Lecture 38: Design Pattern-II.
Chapter 17 Designing with Responsibilities. Fig
Singleton Pattern Presented By:- Navaneet Kumar ise
1 Lecture Material Design Patterns Visitor Client-Server Factory Singleton.
GoF Patterns (GoF) popo.
Low Budget Productions, LLC
Conception OBJET GRASP Patterns
Design Patterns Introduction
Design Patterns (GoF) contains the creational patterns:
SOEN 343 Software Design Computer Science and Software Engineering Department Concordia University Fall 2005 Instructor: Patrice Chalin.
GoF Design Patterns (Ch. 26). GoF Design Patterns Adapter Factory Singleton Strategy Composite Façade Observer (Publish-Subscribe)
SOEN 343 Software Design Computer Science and Software Engineering Department Concordia University Fall 2004 Instructor: Patrice Chalin.
SOEN 343 Software Design Computer Science and Software Engineering Department Concordia University Fall 2004 Instructor: Patrice Chalin.
SOEN 343 Software Design Computer Science and Software Engineering Department Concordia University Fall 2005 Instructor: Patrice Chalin.
SOEN 343 Software Design Computer Science and Software Engineering Department Concordia University Fall 2004 Instructor: Patrice Chalin.
Object Oriented Design Patterns - Creational Patterns
SOEN 343 Software Design Computer Science and Software Engineering Department Concordia University Fall 2004 Instructor: Patrice Chalin.
SOEN 343 Software Design Computer Science and Software Engineering Department Concordia University Fall 2005 Instructor: Patrice Chalin.
SOEN 343 Software Design Computer Science and Software Engineering Department Concordia University Fall 2004 Instructor: Patrice Chalin.
SOEN 343 Software Design Computer Science and Software Engineering Department Concordia University Fall 2004 Instructor: Patrice Chalin.
SOEN 343 Software Design Computer Science and Software Engineering Department Concordia University Fall 2004 Instructor: Patrice Chalin.
SOEN 343 Software Design Computer Science and Software Engineering Department Concordia University Fall 2005 Instructor: Patrice Chalin.
SOEN 343 Software Design Computer Science and Software Engineering Department Concordia University Fall 2004 Instructor: Patrice Chalin.
SOEN 343 Software Design Computer Science and Software Engineering Department Concordia University Fall 2004 Instructor: Patrice Chalin.
SOEN 343 Software Design Computer Science and Software Engineering Department Concordia University Fall 2005 Instructor: Patrice Chalin.
SOEN 343 Software Design Computer Science and Software Engineering Department Concordia University Fall 2004 Instructor: Patrice Chalin.
SOEN 343 Software Design Computer Science and Software Engineering Department Concordia University Fall 2004 Instructor: Patrice Chalin.
GoF Design Patterns (Ch. 26)
CS 350 – Software Design Singleton – Chapter 21
SOEN 343 Software Design Computer Science and Software Engineering Department Concordia University Fall 2004 Instructor: Patrice Chalin.
SOEN 343 Software Design Computer Science and Software Engineering Department Concordia University Fall 2004 Instructor: Patrice Chalin.
SOEN 343 Software Design Computer Science and Software Engineering Department Concordia University Fall 2004 Instructor: Patrice Chalin.
Design Patterns Imran Rashid CTO at ManiWeber Technologies.
SOEN 343 Software Design Computer Science and Software Engineering Department Concordia University Fall 2004 Instructor: Patrice Chalin.
SOEN 343 Software Design Computer Science and Software Engineering Department Concordia University Fall 2004 Instructor: Patrice Chalin.
SOEN 343 Software Design Computer Science and Software Engineering Department Concordia University Fall 2004 Instructor: Patrice Chalin.
GoF Patterns Ch. 26.
Object Oriented System Design Responsibilities
Presentation transcript:

SOEN 343 Software Design Computer Science and Software Engineering Department Concordia University Fall 2005 Instructor: Patrice Chalin

Agenda – Lecture 11a GRASP interrelationships. Dice Game Test class: a solution. GoF (Simple) Factory Singleton 1/17/2019 SOEN 343, © P.Chalin,

GRASP Information Expert Creator High Cohesion Low Coupling Controller Polymorphism Pure Fabrication Indirection Protected Variations 1/17/2019 SOEN 343, © P.Chalin,

GRASP: Interrelationships This is how Larman illustrates the interrelationships between the GRASP. 1/17/2019 SOEN 343, © P.Chalin,

Dice Game Test Class: A Solution (Given in class) 1/17/2019 SOEN 343, © P.Chalin,

Gang Of Four Gamma, Helm, Johnson, Vlissides SOEN 343, © P.Chalin, Erich 1/17/2019 SOEN 343, © P.Chalin,

GoF Pattern Summary (& Relationhips) [Picutre (c) GoF CD] 1/17/2019 SOEN 343, © P.Chalin,

Design Issue: Ensure No More Than One Instance of a Class is Created Given a class C, how can we ensure that only one instance of C is ever created? 1/17/2019 SOEN 343, © P.Chalin,

Converting C to a Singleton. 1/17/2019 SOEN 343, © P.Chalin,

Singleton Pattern Notice: Constructor is no longer public. To access the instance use getUniqueInstance(). All other attribute and method declarations of C stay the same. 1/17/2019 SOEN 343, © P.Chalin,

«Singleton» C.getUniqueInstance() public static C getUniqueInstance() { if(uniqueInstance == null) { uniqueInstance = new C(); } return uniqueInstance; 1/17/2019 SOEN 343, © P.Chalin,

Thread-safe Creation Method public static synchronized C getUn…() { … } 1/17/2019 SOEN 343, © P.Chalin,

Singleton: Design Alternatives/Issues Create a class with static attributes and methods. Trade-offs: consider how easy the following are: Adapting the design so that x instances can be created (where x > 1). Subclassing. Passing the instance as a parameter. … (See Larman05, Section 26.5) 1/17/2019 SOEN 343, © P.Chalin,

Singleton: Design Issues (Cont’d) See Larman05, Section 26.5 for discussion of Design trade-offs, including eager/lazy evaluation of Singleton.uniqueInstance see. 1/17/2019 SOEN 343, © P.Chalin,

Singleton & UML 1/17/2019 SOEN 343, © P.Chalin,

Singleton & UML Larman05, fig. 1/17/2019 SOEN 343, © P.Chalin,