Design Patterns Revisited

Size: px
Start display at page:

Download "Design Patterns Revisited"

Transcription

1 CSC 7322 : Object Oriented Development J Paul Gibson, A207 paul.gibson@int-edu.eu Design Patterns Revisited /~gibson/teaching/csc7322/l13-designpatterns-2.pdf 2013: J Paul Gibson TSP: Software Engineering CSC7322/DesignPatterns.1

2 Learning by PBL the patterns selected 1. Singleton - creational 2. Iterator behavioural 3. Visitor behavioural 4. Proxy - structural 5. Factory - creational 6. Decorator structural 7. Facade - structural 8. Adapter - structural 9. Chain Of Responsibility - behavioural 10. MVC a composite pattern (Strategy, Observer, Composite) 2013: J Paul Gibson TSP: Software Engineering CSC7322/DesignPatterns.2

3 Decorator Pattern See - Intent Attach additional responsibilities to an object dynamically. Decorators provide a flexible alternative to subclassing for extending functionality. Client-specified embellishment of a core object by recursively wrapping it. Wrapping a gift, putting it in a box, and wrapping the box. Problem You want to add behavior or state to individual objects at run-time. Inheritance is not feasible because it is static and applies to an entire class. 2013: J Paul Gibson TSP: Software Engineering CSC7322/DesignPatterns.3

4 Decorator Pattern See - Relation to other patterns Adapter provides a different interface to its subject. Proxy provides the same interface. Decorator provides an enhanced interface. Adapter changes an object s interface, Decorator enhances an object s responsibilities. Decorator is thus more transparent to the client. As a consequence, Decorator supports recursive composition, which isn t possible with pure Adapters. Composite and Decorator have similar structure diagrams, reflecting the fact that both rely on recursive composition to organize an open-ended number of objects. A Decorator can be viewed as a degenerate Composite with only one component. However, a Decorator adds additional responsibilities - it isn t intended for object aggregation. 2013: J Paul Gibson TSP: Software Engineering CSC7322/DesignPatterns.4

5 Decorator Pattern See - Relation to other patterns Decorator is designed to let you add responsibilities to objects without subclassing. Composite s focus is not on embellishment but on representation. These intents are distinct but complementary. Consequently, Composite and Decorator are often used in concert. Composite could use Chain of Responsibility to let components access global properties through their parent. It could also use Decorator to override these properties on parts of the composition. Decorator and Proxy have different purposes but similar structures. Both describe how to provide a level of indirection to another object, and the implementations keep a reference to the object to which they forward requests. Decorator lets you change the skin of an object. Strategy lets you change the guts. Most of these patterns use a form of delegation (which is not usually considered a pattern in its own right) 2013: J Paul Gibson TSP: Software Engineering CSC7322/DesignPatterns.5

6 Decorator Pattern Class Diagram UML The following diagram shows structure of typical decorator pattern, the diagram was taken dofactory.com 2013: J Paul Gibson TSP: Software Engineering CSC7322/DesignPatterns.6

7 Decorator Pattern Class Diagram UML The following diagram shows a concrete example of an Account (from : J Paul Gibson TSP: Software Engineering CSC7322/DesignPatterns.7

8 Decorator Pattern Sequence Diagram UML The following diagram shows a concrete example of Account dynamic behaviour 2013: J Paul Gibson TSP: Software Engineering CSC7322/DesignPatterns.8

9 Decorator Pattern Sequence Diagram UML: explanation 1. Call Bank.CreateAccount. 2. The Bank instantiates an Account class. 3. The Bank creates an AccountDepositValidator and wrap Account with it 4. The Bank return an instance of IAccount. 5. Deposit is called on IAccount which is an instance of AccountDepositValidator 6. AccountDepositValidator calls Validate 7. AccountDepositValidator call GetValidations to retrieve the list of validation to evaluate 8. An AmountGreaterThaZeroValidation is created 9. IsValid returns true 10. AccountDepositValidator call base Deposit method 11. Balance value is updated 2013: J Paul Gibson TSP: Software Engineering CSC7322/DesignPatterns.9

10 Decorator Problem : The classic Christmas tree (revisited) Problem: Examine the Java code in the package p_decorator in the folder Patterns (~gibson/teaching/csc7322/code/decorator.zip) 2013: J Paul Gibson TSP: Software Engineering CSC7322/DesignPatterns.10

11 Decorator Christmas Tree package specifications; public interface BranchOfTreeSpecification { public void animate(); public String getdecorations(); 2013: J Paul Gibson TSP: Software Engineering CSC7322/DesignPatterns.11

12 Decorator Christmas Tree package specifications; public abstract class BranchDecoratorSpecifiation implements BranchOfTreeSpecification{ protected BranchOfTreeSpecification decoratedbranch; public BranchDecoratorSpecifiation(BranchOfTreeSpecification branchtodecorate){ decoratedbranch= branchtodecorate; public void animate(){decoratedbranch.animate(); 2013: J Paul Gibson TSP: Software Engineering CSC7322/DesignPatterns.12

13 Decorator - Christmas Tree package models; import specifications.branchoftreespecification; public class UndecoratedBranch implements BranchOfTreeSpecification{ public void animate(){ public String getdecorations(){ return ""; 2013: J Paul Gibson TSP: Software Engineering CSC7322/DesignPatterns.13

14 Decorator - Christmas Tree package models; import specifications.branchdecoratorspecification; import specifications.branchoftreespecification; public class BallDecorator extends BranchDecoratorSpecification{ boolean spinning; public BallDecorator(BranchOfTreeSpecification branchoftree){ super(branchoftree); spinning = true; public String getdecorations(){ String str = decoratedbranch.getdecorations(); if (spinning) str = str +" Spinning"; str = str+ " Ball."; return str; public void animate(){ decoratedbranch.animate(); spinning =!spinning; 2013: J Paul Gibson TSP: Software Engineering CSC7322/DesignPatterns.14

15 Decorator Christmas Tree package models; import specifications.branchdecoratorspecifiation; import specifications.branchoftreespecification; public class LightsDecorator extends BranchDecoratorSpecifiation{ String colour;public LightsDecorator(BranchOfTreeSpecification branchoftree){ super(branchoftree); colour = "red"; public String getdecorations(){ String str = decoratedbranch.getdecorations(); str =str+ " colour = "+colour; return str; public void animate(){ decoratedbranch.animate(); if (colour.equals("red")) colour ="white"; else if (colour.equals("white")) colour ="blue"; else colour = "red"; 2013: J Paul Gibson TSP: Software Engineering CSC7322/DesignPatterns.15

16 Decorator Christmas Tree public class TestBallDecorator { public static void main (String [] args){ BranchOfTreeSpecification plainbranch = new UndecoratedBranch(); BranchOfTreeSpecification decoratedbranch = new BallDecorator( plainbranch); BranchOfTreeSpecification redecoratedbranch = new BallDecorator( new BallDecorator( plainbranch)); System.out.println("plainBranch.getDecorations() ="+plainbranch.getdecorations()); System.out.println("decoratedBranch.getDecorations() ="+decoratedbranch.getdecorations()); System.out.println("reDecoratedBranch.getDecorations() =" +redecoratedbranch.getdecorations()); plainbranch.animate(); System.out.println("plainBranch.animate.getDecorations() ="+plainbranch.getdecorations()); decoratedbranch.animate(); System.out.println("decoratedBranch.animate.getDecorations() ="+decoratedbranch.getdecorations()); redecoratedbranch.animate(); System.out.println("reDecoratedBranch.animate.getDecorations() =" +redecoratedbranch.getdecorations()); 2013: J Paul Gibson TSP: Software Engineering CSC7322/DesignPatterns.16

17 Decorator - Christmas Tree 2013: J Paul Gibson TSP: Software Engineering CSC7322/DesignPatterns.17

18 Decorator Christmas Tree TO DO: Test Lights Decoration Test Lights with Balls Decoration Add new Decoration (Stars, eg) Test 3 Decorations together Create XMAS tree with 4 branches: 2 Lights and 2 Balls 2 Lights and 3 Stars 2 Stars and 3 Balls 2 Lights and 2 Stars and 2 Balls PROBLEM: Ensure that the state of decorations on the same branch of tree is coordinated (but not necessarily on different branches) OPTION: Maximum number of decorations on any branch is : J Paul Gibson TSP: Software Engineering CSC7322/DesignPatterns.18

19 Decorator Christmas Tree What to learn from the problem: If you really need multiple instances of same decoration then this pattern is probably not correct. The following 4 sentences seem equivalent but may lead to different designs/implementations: The branch «is a» branch with lights and stars The branch «is a» branch with lights and «is a» branch with stars The branch «has» lights and stars The branch «has» lights and the branch «has» stars Knowing which design is best depends on knowing precisely what is the intended/required behaviour. The decorator is not intended to allow statements like: The branch «is a» branch with lights and «is a» branch with lights 2013: J Paul Gibson TSP: Software Engineering CSC7322/DesignPatterns.19

20 Decorator Christmas Tree Solving the problem: If we really need multiple decorations of the same type on a single branch do not use the decorator pattern in this way We should fix the decorator pattern so that decorating a branch with ball behaviour that has already been decorated with ball behaviour is either: Handled by an exception, or Ignored TO DO implement one of these solutions, and retest the new behaviour NOTE: As requirements change you may be tempted to compromise your system by holding on to a pattern which is no longer appropriate 2013: J Paul Gibson TSP: Software Engineering CSC7322/DesignPatterns.20

21 Facade versus Adapter Intuitively, what are the differences? 2013: J Paul Gibson TSP: Software Engineering CSC7322/DesignPatterns.21

22 Facade versus Adapter 2013: J Paul Gibson TSP: Software Engineering CSC7322/DesignPatterns.22

23 Facade versus Adapter 2013: J Paul Gibson TSP: Software Engineering CSC7322/DesignPatterns.23

24 Facade - provides a unified interface to a set of interfaces in a subsystem Identify a simpler, unified interface for the subsystem/component. Design a wrapper class that encapsulates the subsystem. The facade/wrapper captures the complexity and collaborations of the component, and delegates to the appropriate methods. The client uses (is coupled to) the Facade only. Facade defines a new interface, whereas Adapter uses an old interface. Remember that Adapter makes two existing interfaces work together as opposed to defining an entirely new one. 2013: J Paul Gibson TSP: Software Engineering CSC7322/DesignPatterns.24

25 Adapter - lets classes work together that couldn t otherwise because of incompatible interfaces Identify the players: the component(s) that want to be accommodated (i.e. the client), and the component that needs to adapt (i.e. the adaptee). Identify the interface that the client requires. Design a wrapper class that can impedance match the adaptee to the client. The adapter/wrapper class has a instance of the adaptee class. The adapter/wrapper class maps the client interface to the adaptee interface. The client uses (is coupled to) the new interface 2013: J Paul Gibson TSP: Software Engineering CSC7322/DesignPatterns.25

26 Realation to Other Design Patterns Adapter and Facade are both wrappers; but they are different kinds of wrappers. The intent of Facade is to produce a simpler interface, and the intent of Adapter is to design to an existing interface. While Facade routinely wraps multiple objects and Adapter wraps a single object; Facade could front-end a single complex object and Adapter could wrap several legacy objects. Adapter makes things work after they re designed; Bridge makes them work before they are. Bridge is designed up-front to let the abstraction and the implementation vary independently. Adapter is retrofitted to make unrelated classes work together. Adapter provides a different interface to its subject. Proxy provides the same interface. Decorator provides an enhanced interface. 2013: J Paul Gibson TSP: Software Engineering CSC7322/DesignPatterns.26

27 The Rectangle Problem A legacy Rectangle component s display() method expects to receive x, y, w, h parameters. But the client wants to pass upper left x and y and lower right x and y. This mismatch can be reconciled by using a design pattern. Question: is this suitable for an adapter or a facade (or something else) Draw the UML design and implement in Java 2013: J Paul Gibson TSP: Software Engineering CSC7322/DesignPatterns.27

28 Chain of responsibility Avoid coupling the sender of a request to its receiver by giving more than one object a chance to handle the request. Chain the receiving objects and pass the request along the chain until an object handles it. 2013: J Paul Gibson TSP: Software Engineering CSC7322/DesignPatterns.28

29 Chain of responsibility Note: Chain of Responsibility can use Command to represent requests as objects THIS MAY BE USEFUL IN YOUR OO PROJECT 2013: J Paul Gibson TSP: Software Engineering CSC7322/DesignPatterns.29

Design Patterns. Dr. Rania Khairy. Software Engineering and Development Tool

Design Patterns. Dr. Rania Khairy. Software Engineering and Development Tool Design Patterns What are Design Patterns? What are Design Patterns? Why Patterns? Canonical Cataloging Other Design Patterns Books: Freeman, Eric and Elisabeth Freeman with Kathy Sierra and Bert Bates.

More information

SDC Design patterns GoF

SDC Design patterns GoF SDC Design patterns GoF Design Patterns The design pattern concept can be viewed as an abstraction of imitating useful parts of other software products. The design pattern is a description of communicating

More information

EPL 603 TOPICS IN SOFTWARE ENGINEERING. Lab 6: Design Patterns

EPL 603 TOPICS IN SOFTWARE ENGINEERING. Lab 6: Design Patterns EPL 603 TOPICS IN SOFTWARE ENGINEERING Lab 6: Design Patterns Links to Design Pattern Material 1 http://www.oodesign.com/ http://www.vincehuston.org/dp/patterns_quiz.html Types of Design Patterns 2 Creational

More information

CSCD01 Engineering Large Software Systems. Design Patterns. Joe Bettridge. Winter With thanks to Anya Tafliovich

CSCD01 Engineering Large Software Systems. Design Patterns. Joe Bettridge. Winter With thanks to Anya Tafliovich CSCD01 Engineering Large Software Systems Design Patterns Joe Bettridge Winter 2018 With thanks to Anya Tafliovich Design Patterns Design patterns take the problems consistently found in software, and

More information

Design Patterns Revisited

Design Patterns Revisited CSC 7322 : Object Oriented Development J Paul Gibson, A207 /~gibson/teaching/csc7322/ Design Patterns Revisited /~gibson/teaching/csc7322/l11-designpatterns-2.pdf 2013: J Paul Gibson TSP: Software Engineering

More information

Object Oriented Methods with UML. Introduction to Design Patterns- Lecture 8

Object Oriented Methods with UML. Introduction to Design Patterns- Lecture 8 Object Oriented Methods with UML Introduction to Design Patterns- Lecture 8 Topics(03/05/16) Design Patterns Design Pattern In software engineering, a design pattern is a general repeatable solution to

More information

Design Patterns. Comp2110 Software Design. Department of Computer Science Australian National University. Second Semester

Design Patterns. Comp2110 Software Design. Department of Computer Science Australian National University. Second Semester Design Patterns Comp2110 Software Design Department of Computer Science Australian National University Second Semester 2005 1 Design Pattern Space Creational patterns Deal with initializing and configuring

More information

CSCD01 Engineering Large Software Systems. Design Patterns. Joe Bettridge. Winter With thanks to Anya Tafliovich

CSCD01 Engineering Large Software Systems. Design Patterns. Joe Bettridge. Winter With thanks to Anya Tafliovich CSCD01 Engineering Large Software Systems Design Patterns Joe Bettridge Winter 2018 With thanks to Anya Tafliovich Design Patterns Design patterns take the problems consistently found in software, and

More information

Object-Oriented Oriented Programming

Object-Oriented Oriented Programming Object-Oriented Oriented Programming Composite Pattern CSIE Department, NTUT Woei-Kae Chen Catalog of Design patterns Creational patterns Abstract Factory, Builder, Factory Method, Prototype, Singleton

More information

Adapter Pattern Structural

Adapter Pattern Structural Adapter Pattern Structural Intent» Convert the interface of a class into a different interface that a client expects.» Lets classes work together that otherwise could not Adapter-1 Class Adapter Motivation

More information

Produced by. Design Patterns. MSc in Communications Software. Eamonn de Leastar

Produced by. Design Patterns. MSc in Communications Software. Eamonn de Leastar Design Patterns MSc in Communications Software Produced by Eamonn de Leastar (edeleastar@wit.ie) Department of Computing, Maths & Physics Waterford Institute of Technology http://www.wit.ie http://elearning.wit.ie

More information

UNIT I Introduction to Design Patterns

UNIT I Introduction to Design Patterns SIDDHARTH GROUP OF INSTITUTIONS :: PUTTUR Siddharth Nagar, Narayanavanam Road 517583 QUESTION BANK (DESCRIPTIVE) Subject with Code : Design Patterns (16MC842) Year & Sem: III-MCA I-Sem Course : MCA Regulation:

More information

Design Pattern. CMPSC 487 Lecture 10 Topics: Design Patterns: Elements of Reusable Object-Oriented Software (Gamma, et al.)

Design Pattern. CMPSC 487 Lecture 10 Topics: Design Patterns: Elements of Reusable Object-Oriented Software (Gamma, et al.) Design Pattern CMPSC 487 Lecture 10 Topics: Design Patterns: Elements of Reusable Object-Oriented Software (Gamma, et al.) A. Design Pattern Design patterns represent the best practices used by experienced

More information

UNIT I Introduction to Design Patterns

UNIT I Introduction to Design Patterns SIDDHARTH GROUP OF INSTITUTIONS :: PUTTUR Siddharth Nagar, Narayanavanam Road 517583 QUESTION BANK (DESCRIPTIVE) Subject with Code : Design Patterns(9F00505c) Year & Sem: III-MCA I-Sem Course : MCA Regulation:

More information

Design Patterns. Manuel Mastrofini. Systems Engineering and Web Services. University of Rome Tor Vergata June 2011

Design Patterns. Manuel Mastrofini. Systems Engineering and Web Services. University of Rome Tor Vergata June 2011 Design Patterns Lecture 1 Manuel Mastrofini Systems Engineering and Web Services University of Rome Tor Vergata June 2011 Definition A pattern is a reusable solution to a commonly occurring problem within

More information

Software Eningeering. Lecture 9 Design Patterns 2

Software Eningeering. Lecture 9 Design Patterns 2 Software Eningeering Lecture 9 Design Patterns 2 Patterns covered Creational Abstract Factory, Builder, Factory Method, Prototype, Singleton Structural Adapter, Bridge, Composite, Decorator, Facade, Flyweight,

More information

Keywords: Abstract Factory, Singleton, Factory Method, Prototype, Builder, Composite, Flyweight, Decorator.

Keywords: Abstract Factory, Singleton, Factory Method, Prototype, Builder, Composite, Flyweight, Decorator. Comparative Study In Utilization Of Creational And Structural Design Patterns In Solving Design Problems K.Wseem Abrar M.Tech., Student, Dept. of CSE, Amina Institute of Technology, Shamirpet, Hyderabad

More information

Design Pattern What is a Design Pattern? Design Pattern Elements. Almas Ansari Page 1

Design Pattern What is a Design Pattern? Design Pattern Elements. Almas Ansari Page 1 What is a Design Pattern? Each pattern Describes a problem which occurs over and over again in our environment,and then describes the core of the problem Novelists, playwrights and other writers rarely

More information

Design Patterns Lecture 2

Design Patterns Lecture 2 Design Patterns Lecture 2 Josef Hallberg josef.hallberg@ltu.se 1 Patterns covered Creational Abstract Factory, Builder, Factory Method, Prototype, Singleton Structural Adapter, Bridge, Composite, Decorator,

More information

Design Patterns Reid Holmes

Design Patterns Reid Holmes Material and some slide content from: - Head First Design Patterns Book - GoF Design Patterns Book Design Patterns Reid Holmes GoF design patterns $ %!!!! $ "! # & Pattern vocabulary Shared vocabulary

More information

The Strategy Pattern Design Principle: Design Principle: Design Principle:

The Strategy Pattern Design Principle: Design Principle: Design Principle: Strategy Pattern The Strategy Pattern defines a family of algorithms, encapsulates each one, and makes them interchangeable. Strategy lets the algorithm vary independently from clients that use it. Design

More information

Design Patterns IV Structural Design Patterns, 1

Design Patterns IV Structural Design Patterns, 1 Structural Design Patterns, 1 COMP2110/2510 Software Design Software Design for SE September 17, 2008 Class Object Department of Computer Science The Australian National University 18.1 1 2 Class Object

More information

Introduction to Software Engineering: Object Design I Reuse & Patterns

Introduction to Software Engineering: Object Design I Reuse & Patterns Introduction to Software Engineering: Object Design I Reuse & Patterns John T. Bell Department of Computer Science University of Illinois, Chicago Based on materials from Bruegge & DuToit 3e, Chapter 8,

More information

Design patterns. Jef De Smedt Beta VZW

Design patterns. Jef De Smedt Beta VZW Design patterns Jef De Smedt Beta VZW Who Beta VZW www.betavzw.org Association founded in 1993 Computer training for the unemployed Computer training for employees (Cevora/Cefora) 9:00-12:30 13:00-16:00

More information

Design Patterns IV. Alexei Khorev. 1 Structural Patterns. Structural Patterns. 2 Adapter Design Patterns IV. Alexei Khorev. Structural Patterns

Design Patterns IV. Alexei Khorev. 1 Structural Patterns. Structural Patterns. 2 Adapter Design Patterns IV. Alexei Khorev. Structural Patterns Structural Design Patterns, 1 1 COMP2110/2510 Software Design Software Design for SE September 17, 2008 2 3 Department of Computer Science The Australian National University 4 18.1 18.2 GoF Structural

More information

SOFTWARE PATTERNS. Joseph Bonello

SOFTWARE PATTERNS. Joseph Bonello SOFTWARE PATTERNS Joseph Bonello MOTIVATION Building software using new frameworks is more complex And expensive There are many methodologies and frameworks to help developers build enterprise application

More information

ADAPTER. Topics. Presented By: Mallampati Bhava Chaitanya

ADAPTER. Topics. Presented By: Mallampati Bhava Chaitanya ADAPTER Presented By: Mallampati Bhava Chaitanya Topics Intent Motivation Applicability Structure Participants & Collaborations Consequences Sample Code Known Uses Related Patterns Intent Convert the interface

More information

Design Patterns: Structural and Behavioural

Design Patterns: Structural and Behavioural Design Patterns: Structural and Behavioural 3 April 2009 CMPT166 Dr. Sean Ho Trinity Western University See also: Vince Huston Review last time: creational Design patterns: Reusable templates for designing

More information

COSC 3351 Software Design. Design Patterns Structural Patterns (I)

COSC 3351 Software Design. Design Patterns Structural Patterns (I) COSC 3351 Software Design Design Patterns Structural Patterns (I) Spring 2008 Purpose Creational Structural Behavioral Scope Class Factory Method Adaptor(class) Interpreter Template Method Object Abstract

More information

Facade and Adapter. Comp-303 : Programming Techniques Lecture 19. Alexandre Denault Computer Science McGill University Winter 2004

Facade and Adapter. Comp-303 : Programming Techniques Lecture 19. Alexandre Denault Computer Science McGill University Winter 2004 Facade and Adapter Comp-303 : Programming Techniques Lecture 19 Alexandre Denault Computer Science McGill University Winter 2004 March 23, 2004 Lecture 19 Comp 303 : Facade and Adapter Page 1 Last lecture...

More information

Exam in TDDB84: Design Patterns,

Exam in TDDB84: Design Patterns, Exam in TDDB84: Design Patterns, 2014-10-24 14-18 Information Observe the following, or risk subtraction of points: 1) Write only the answer to one task on one sheet. Use only the front side of the sheets

More information

An Introduction to Patterns

An Introduction to Patterns An Introduction to Patterns Robert B. France Colorado State University Robert B. France 1 What is a Pattern? - 1 Work on software development patterns stemmed from work on patterns from building architecture

More information

A Reconnaissance on Design Patterns

A Reconnaissance on Design Patterns A Reconnaissance on Design Patterns M.Chaithanya Varma Student of computer science engineering, Sree Vidhyanikethan Engineering college, Tirupati, India ABSTRACT: In past decade, design patterns have been

More information

Idioms and Design Patterns. Martin Skogevall IDE, Mälardalen University

Idioms and Design Patterns. Martin Skogevall IDE, Mälardalen University Idioms and Design Patterns Martin Skogevall IDE, Mälardalen University 2005-04-07 Acronyms Object Oriented Analysis and Design (OOAD) Object Oriented Programming (OOD Software Design Patterns (SDP) Gang

More information

OODP Session 4. Web Page: Visiting Hours: Tuesday 17:00 to 19:00

OODP Session 4.   Web Page:   Visiting Hours: Tuesday 17:00 to 19:00 OODP Session 4 Session times PT group 1 Monday 18:00 21:00 room: Malet 403 PT group 2 Thursday 18:00 21:00 room: Malet 407 FT Tuesday 13:30 17:00 room: Malet 404 Email: oded@dcs.bbk.ac.uk Web Page: http://www.dcs.bbk.ac.uk/~oded

More information

Think of drawing/diagramming editors. ECE450 Software Engineering II. The problem. The Composite pattern

Think of drawing/diagramming editors. ECE450 Software Engineering II. The problem. The Composite pattern Think of drawing/diagramming editors ECE450 Software Engineering II Drawing/diagramming editors let users build complex diagrams out of simple components The user can group components to form larger components......which

More information

Modellistica Medica. Maria Grazia Pia, INFN Genova. Scuola di Specializzazione in Fisica Sanitaria Genova Anno Accademico

Modellistica Medica. Maria Grazia Pia, INFN Genova. Scuola di Specializzazione in Fisica Sanitaria Genova Anno Accademico Modellistica Medica Maria Grazia Pia INFN Genova Scuola di Specializzazione in Fisica Sanitaria Genova Anno Accademico 2002-2003 Lezione 9 OO modeling Design Patterns Structural Patterns Behavioural Patterns

More information

Design Patterns V Structural Design Patterns, 2

Design Patterns V Structural Design Patterns, 2 Structural Design Patterns, 2 COMP2110/2510 Software Design Software Design for SE September 17, 2008 Department of Computer Science The Australian National University 19.1 1 2 Formal 3 Formal 4 Formal

More information

INSTITUTE OF AERONAUTICAL ENGINEERING

INSTITUTE OF AERONAUTICAL ENGINEERING INSTITUTE OF AERONAUTICAL ENGINEERING (Autonomous) Dundigal, Hyderabad -500 0 COMPUTER SCIENCE AND ENGINEERING TUTORIAL QUESTION BANK Course Name : DESIGN PATTERNS Course Code : A7050 Class : IV B. Tech

More information

Trusted Components. Reuse, Contracts and Patterns. Prof. Dr. Bertrand Meyer Dr. Karine Arnout

Trusted Components. Reuse, Contracts and Patterns. Prof. Dr. Bertrand Meyer Dr. Karine Arnout 1 Last update: 2 November 2004 Trusted Components Reuse, Contracts and Patterns Prof. Dr. Bertrand Meyer Dr. Karine Arnout 2 Lecture 5: Design patterns Agenda for today 3 Overview Benefits of patterns

More information

Behavioral patterns. Command Iterator Observer Strategy Template method

Behavioral patterns. Command Iterator Observer Strategy Template method Designpatterns Behavioral patterns Command Iterator Observer Strategy Template method Command Invoker: asks the command to carry out the request @CommandPattern.Invoker Command: defines an interface for

More information

Software Engineering Prof. Rushikesh K.Joshi IIT Bombay Lecture-15 Design Patterns

Software Engineering Prof. Rushikesh K.Joshi IIT Bombay Lecture-15 Design Patterns Software Engineering Prof. Rushikesh K.Joshi IIT Bombay Lecture-15 Design Patterns Today we are going to talk about an important aspect of design that is reusability of design. How much our old design

More information

Topics in Object-Oriented Design Patterns

Topics in Object-Oriented Design Patterns Software design Topics in Object-Oriented Design Patterns Material mainly from the book Design Patterns by Erich Gamma, Richard Helm, Ralph Johnson and John Vlissides; slides originally by Spiros Mancoridis;

More information

Department of Information Technology

Department of Information Technology LECTURE NOTES ON DESIGN PATTERNS B.TECH IV-I JNTUH(R15) Ms. B. REKHA Assistant Professor Department of Information Technology INSTITUTE OF AERONAUTICAL ENGINEERING (Autonomous) Dundigal 500 043, Hyderabad

More information

Appendix A - Glossary(of OO software term s)

Appendix A - Glossary(of OO software term s) Appendix A - Glossary(of OO software term s) Abstract Class A class that does not supply an implementation for its entire interface, and so consequently, cannot be instantiated. ActiveX Microsoft s component

More information

Software Design Patterns. Background 1. Background 2. Jonathan I. Maletic, Ph.D.

Software Design Patterns. Background 1. Background 2. Jonathan I. Maletic, Ph.D. Software Design Patterns Jonathan I. Maletic, Ph.D. Department of Computer Science Kent State University J. Maletic 1 Background 1 Search for recurring successful designs emergent designs from practice

More information

Produced by. Design Patterns. MSc in Communications Software. Eamonn de Leastar

Produced by. Design Patterns. MSc in Communications Software. Eamonn de Leastar Design Patterns MSc in Communications Software Produced by Eamonn de Leastar (edeleastar@wit.ie) Department of Computing, Maths & Physics Waterford Institute of Technology http://www.wit.ie http://elearning.wit.ie

More information

Socket attaches to a Ratchet. 2) Bridge Decouple an abstraction from its implementation so that the two can vary independently.

Socket attaches to a Ratchet. 2) Bridge Decouple an abstraction from its implementation so that the two can vary independently. Gang of Four Software Design Patterns with examples STRUCTURAL 1) Adapter Convert the interface of a class into another interface clients expect. It lets the classes work together that couldn't otherwise

More information

Design to interfaces. Favor composition over inheritance Find what varies and encapsulate it

Design to interfaces. Favor composition over inheritance Find what varies and encapsulate it Design Patterns The Gang of Four suggests a few strategies for creating good o-o designs, including Façade Design to interfaces. Favor composition over inheritance Find what varies and encapsulate it One

More information

Composite Pattern. IV.4 Structural Pattern

Composite Pattern. IV.4 Structural Pattern IV.4 Structural Pattern Motivation: Compose objects to realize new functionality Flexible structures that can be changed at run-time Problems: Fixed class for every composition is required at compile-time

More information

APPLYING DESIGN PATTERNS TO SCA IMPLEMENTATIONS

APPLYING DESIGN PATTERNS TO SCA IMPLEMENTATIONS APPLYING DESIGN PATTERNS TO SCA IMPLEMENTATIONS Adem Zumbul (TUBITAK-UEKAE, Kocaeli, Turkey, ademz@uekae.tubitak.gov.tr); Tuna Tugcu (Bogazici University, Istanbul, Turkey, tugcu@boun.edu.tr) ABSTRACT

More information

Lecture 17: Patterns Potpourri. Copyright W. Howden 1

Lecture 17: Patterns Potpourri. Copyright W. Howden 1 Lecture 17: Patterns Potpourri Copyright W. Howden 1 GOF Patterns GOF: Gamma, Helm, Johnson, Vlissides Design Patterns, Addison Wesley, 1995 Patterns we have seen so far Creational Patterns e.g. Factory,

More information

Design of Software Systems (Ontwerp van SoftwareSystemen) Design Patterns Reference. Roel Wuyts

Design of Software Systems (Ontwerp van SoftwareSystemen) Design Patterns Reference. Roel Wuyts Design of Software Systems (Ontwerp van SoftwareSystemen) Design Patterns Reference 2015-2016 Visitor See lecture on design patterns Design of Software Systems 2 Composite See lecture on design patterns

More information

Applying Design Patterns to SCA Implementations

Applying Design Patterns to SCA Implementations Applying Design Patterns to SCA Implementations Adem ZUMBUL (TUBITAK-UEKAE, ademz@uekae.tubitak.gov.tr) Tuna TUGCU (Bogazici University, tugcu@boun.edu.tr) SDR Forum Technical Conference, 26-30 October

More information

Using Design Patterns in Java Application Development

Using Design Patterns in Java Application Development Using Design Patterns in Java Application Development ExxonMobil Research & Engineering Co. Clinton, New Jersey Michael P. Redlich (908) 730-3416 michael.p.redlich@exxonmobil.com About Myself Degree B.S.

More information

DESIGN PATTERN - INTERVIEW QUESTIONS

DESIGN PATTERN - INTERVIEW QUESTIONS DESIGN PATTERN - INTERVIEW QUESTIONS http://www.tutorialspoint.com/design_pattern/design_pattern_interview_questions.htm Copyright tutorialspoint.com Dear readers, these Design Pattern Interview Questions

More information

Object-Oriented Oriented Programming Adapter Pattern. CSIE Department, NTUT Woei-Kae Chen

Object-Oriented Oriented Programming Adapter Pattern. CSIE Department, NTUT Woei-Kae Chen Object-Oriented Oriented Programming Adapter Pattern CSIE Department, NTUT Woei-Kae Chen Adapter: Intent Convert the interface of a class into another interface clients expect. Adapter lets classes work

More information

Design Patterns Cont. CSE 110 Discussion - Week 9

Design Patterns Cont. CSE 110 Discussion - Week 9 Design Patterns Cont. CSE 110 Discussion - Week 9 Factory Method - Decouple object creation from implementation details - Allows you to use an object ( product ) without knowing about creation - Often

More information

CSCD01 Engineering Large Software Systems. Design Patterns. Joe Bettridge. Winter With thanks to Anya Tafliovich

CSCD01 Engineering Large Software Systems. Design Patterns. Joe Bettridge. Winter With thanks to Anya Tafliovich CSCD01 Engineering Large Software Systems Design Patterns Joe Bettridge Winter 2018 With thanks to Anya Tafliovich Design Patterns Design patterns take the problems consistently found in software, and

More information

LECTURE NOTES ON DESIGN PATTERNS MCA III YEAR, V SEMESTER (JNTUA-R09)

LECTURE NOTES ON DESIGN PATTERNS MCA III YEAR, V SEMESTER (JNTUA-R09) LECTURE NOTES ON DESIGN PATTERNS MCA III YEAR, V SEMESTER (JNTUA-R09) Mr. B KRISHNA MURTHI M.TECH, MISTE. Assistant Professor DEPARTMENT OF MASTER OF COMPUTER APPLICATIONS CHADALAWADA RAMANAMMA ENGINEERING

More information

Summary of the course lectures

Summary of the course lectures Summary of the course lectures 1 Components and Interfaces Components: Compile-time: Packages, Classes, Methods, Run-time: Objects, Invocations, Interfaces: What the client needs to know: Syntactic and

More information

DESIGN PATTERNS SURESH BABU M ASST PROFESSOR VJIT

DESIGN PATTERNS SURESH BABU M ASST PROFESSOR VJIT DESIGN PATTERNS SURESH BABU M ASST PROFESSOR VJIT L1 Each pattern Describes a problem which occurs over and over again in our environment,and then describes the core of the problem Novelists, playwrights

More information

Lecture 20: Design Patterns II

Lecture 20: Design Patterns II Lecture 20: Design Patterns II Software System Design and Implementation ITCS/ITIS 6112/8112 001 Fall 2008 Dr. Jamie Payton Department of Computer Science University of North Carolina at Charlotte Nov.

More information

administrivia today UML start design patterns Tuesday, September 28, 2010

administrivia today UML start design patterns Tuesday, September 28, 2010 administrivia Assignment 2? promise to get past assignment 1 back soon exam on monday review slides are posted your responsibility to review covers through last week today UML start design patterns 1 Unified

More information

Object-Oriented Concepts and Design Principles

Object-Oriented Concepts and Design Principles Object-Oriented Concepts and Design Principles Signature Specifying an object operation or method involves declaring its name, the objects it takes as parameters and its return value. Known as an operation

More information

The GoF Design Patterns Reference

The GoF Design Patterns Reference The GoF Design Patterns Reference Version.0 / 0.0.07 / Printed.0.07 Copyright 0-07 wsdesign. All rights reserved. The GoF Design Patterns Reference ii Table of Contents Preface... viii I. Introduction....

More information

Design Patterns. An introduction

Design Patterns. An introduction Design Patterns An introduction Introduction Designing object-oriented software is hard, and designing reusable object-oriented software is even harder. Your design should be specific to the problem at

More information

Brief Note on Design Pattern

Brief Note on Design Pattern Brief Note on Design Pattern - By - Channu Kambalyal channuk@yahoo.com This note is based on the well-known book Design Patterns Elements of Reusable Object-Oriented Software by Erich Gamma et., al.,.

More information

The Adapter Pattern. Interface with anything!

The Adapter Pattern. Interface with anything! The Adapter Pattern Interface with anything! Adapter in a Nutshell - An adapter takes an object with one interface, and changes the interface to make it look like something it s not. - Allows two objects

More information

Design patterns. OOD Lecture 6

Design patterns. OOD Lecture 6 Design patterns OOD Lecture 6 Next lecture Monday, Oct 1, at 1:15 pm, in 1311 Remember that the poster sessions are in two days Thursday, Sep 27 1:15 or 3:15 pm (check which with your TA) Room 2244 + 2245

More information

Design Patterns Reid Holmes

Design Patterns Reid Holmes Material and some slide content from: - Head First Design Patterns Book - GoF Design Patterns Book Design Patterns Reid Holmes GoF design patterns $ %!!!! $ "! # & Pattern vocabulary Shared vocabulary

More information

Design Pattern: Composite

Design Pattern: Composite Design Pattern: Composite Intent Compose objects into tree structures to represent part-whole hierarchies. Composite lets clients treat individual objects and compositions of objects uniformly. Motivation

More information

Design Patterns. "Gang of Four"* Design Patterns. "Gang of Four" Design Patterns. Design Pattern. CS 247: Software Engineering Principles

Design Patterns. Gang of Four* Design Patterns. Gang of Four Design Patterns. Design Pattern. CS 247: Software Engineering Principles CS 247: Software Engineering Principles Design Patterns Reading: Freeman, Robson, Bates, Sierra, Head First Design Patterns, O'Reilly Media, Inc. 2004 Ch Strategy Pattern Ch 7 Adapter and Facade patterns

More information

Slide 1. Design Patterns. Prof. Mirco Tribastone, Ph.D

Slide 1. Design Patterns. Prof. Mirco Tribastone, Ph.D Slide 1 Design Patterns Prof. Mirco Tribastone, Ph.D. 22.11.2011 Introduction Slide 2 Basic Idea The same (well-established) schema can be reused as a solution to similar problems. Muster Abstraktion Anwendung

More information

CS 247: Software Engineering Principles. Design Patterns

CS 247: Software Engineering Principles. Design Patterns CS 247: Software Engineering Principles Design Patterns Reading: Freeman, Robson, Bates, Sierra, Head First Design Patterns, O'Reilly Media, Inc. 2004 Ch 1 Strategy Pattern Ch 7 Adapter and Facade patterns

More information

A few important patterns and their connections

A few important patterns and their connections A few important patterns and their connections Perdita Stevens School of Informatics University of Edinburgh Plan Singleton Factory method Facade and how they are connected. You should understand how to

More information

Plan. A few important patterns and their connections. Singleton. Singleton: class diagram. Singleton Factory method Facade

Plan. A few important patterns and their connections. Singleton. Singleton: class diagram. Singleton Factory method Facade Plan A few important patterns and their connections Perdita Stevens School of Informatics University of Edinburgh Singleton Factory method Facade and how they are connected. You should understand how to

More information

Software Design COSC 4353/6353 D R. R A J S I N G H

Software Design COSC 4353/6353 D R. R A J S I N G H Software Design COSC 4353/6353 D R. R A J S I N G H Design Patterns What are design patterns? Why design patterns? Example DP Types Toolkit, Framework, and Design Pattern A toolkit is a library of reusable

More information

Object-Oriented Oriented Programming Adapter Pattern

Object-Oriented Oriented Programming Adapter Pattern Object-Oriented Oriented Programming Pattern CSIE Department, NTUT Woei-Kae Chen : Intent Convert the interface of a class into another interface clients expect. lets classes work together that could not

More information

CSCI Object Oriented Design: Frameworks and Design Patterns George Blankenship. Frameworks and Design George Blankenship 1

CSCI Object Oriented Design: Frameworks and Design Patterns George Blankenship. Frameworks and Design George Blankenship 1 CSCI 6234 Object Oriented Design: Frameworks and Design Patterns George Blankenship Frameworks and Design George Blankenship 1 Background A class is a mechanisms for encapsulation, it embodies a certain

More information

be used for more than one use case (for instance, for use cases Create User and Delete User, one can have one UserController, instead of two separate

be used for more than one use case (for instance, for use cases Create User and Delete User, one can have one UserController, instead of two separate UNIT 4 GRASP GRASP: Designing objects with responsibilities Creator Information expert Low Coupling Controller High Cohesion Designing for visibility - Applying GoF design patterns adapter, singleton,

More information

Design Patterns. GoF design patterns catalog

Design Patterns. GoF design patterns catalog Design Patterns GoF design patterns catalog OMT notations - classes OMT notation - relationships Inheritance - triangle Aggregation - diamond Acquaintance keeps a reference solid line with arrow Creates

More information

CSCI 253. Overview. The Elements of a Design Pattern. George Blankenship 1. Object Oriented Design: Iterator Pattern George Blankenship

CSCI 253. Overview. The Elements of a Design Pattern. George Blankenship 1. Object Oriented Design: Iterator Pattern George Blankenship CSCI 253 Object Oriented Design: Iterator Pattern George Blankenship George Blankenship 1 Creational Patterns Singleton Abstract factory Factory Method Prototype Builder Overview Structural Patterns Composite

More information

Design Patterns in C++

Design Patterns in C++ Design Patterns in C++ Structural Patterns Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa March 23, 2011 G. Lipari (Scuola Superiore Sant Anna) Structural patterns March

More information

Tuesday, October 4. Announcements

Tuesday, October 4. Announcements Tuesday, October 4 Announcements www.singularsource.net Donate to my short story contest UCI Delta Sigma Pi Accepts business and ICS students See Facebook page for details Slide 2 1 Design Patterns Design

More information

SYLLABUS CHAPTER - 1 [SOFTWARE REUSE SUCCESS FACTORS] Reuse Driven Software Engineering is a Business

SYLLABUS CHAPTER - 1 [SOFTWARE REUSE SUCCESS FACTORS] Reuse Driven Software Engineering is a Business Contents i UNIT - I UNIT - II UNIT - III CHAPTER - 1 [SOFTWARE REUSE SUCCESS FACTORS] Software Reuse Success Factors. CHAPTER - 2 [REUSE-DRIVEN SOFTWARE ENGINEERING IS A BUSINESS] Reuse Driven Software

More information

In this Lecture you will Learn: Design Patterns. Patterns vs. Frameworks. Patterns vs. Frameworks

In this Lecture you will Learn: Design Patterns. Patterns vs. Frameworks. Patterns vs. Frameworks In this Lecture you will Learn: Design Patterns Chapter 15 What types of patterns have been identified in software development How to apply design patterns during software development The benefits and

More information

Design Patterns. (and anti-patterns)

Design Patterns. (and anti-patterns) Design Patterns (and anti-patterns) Design Patterns The Gang of Four defined the most common object-oriented patterns used in software. These are only the named ones Lots more variations exist Design Patterns

More information

CSE 70 Final Exam Fall 2009

CSE 70 Final Exam Fall 2009 Signature cs70f Name Student ID CSE 70 Final Exam Fall 2009 Page 1 (10 points) Page 2 (16 points) Page 3 (22 points) Page 4 (13 points) Page 5 (15 points) Page 6 (20 points) Page 7 (9 points) Page 8 (15

More information

A Rapid Overview of UML

A Rapid Overview of UML A Rapid Overview of UML The Unified dmodeling Language (UML) Emerged in the mid 90s as the de facto standard for softwareengineering engineering design Use case diagram depicts user interaction with system

More information

Chapter 8, Design Patterns Visitor

Chapter 8, Design Patterns Visitor Chapter 8, Design Patterns Visitor Using UML, Patterns, and Java Object-Oriented Software Engineering Pattern A Pattern Taxonomy Structural Pattern Behavioral Pattern Creational Pattern Composite Decorator

More information

Ingegneria del Software Corso di Laurea in Informatica per il Management. Design Patterns part 1

Ingegneria del Software Corso di Laurea in Informatica per il Management. Design Patterns part 1 Ingegneria del Software Corso di Laurea in Informatica per il Management Design Patterns part 1 Davide Rossi Dipartimento di Informatica Università di Bologna Pattern Each pattern describes a problem which

More information

An Introduction to Patterns

An Introduction to Patterns An Introduction to Patterns Robert B. France Colorado State University Robert B. France 1 What is a Pattern? Patterns are intended to capture the best available software development experiences in the

More information

Design Pattern and Software Architecture: IV. Design Pattern

Design Pattern and Software Architecture: IV. Design Pattern Design Pattern and Software Architecture: IV. Design Pattern AG Softwaretechnik Raum E 3.165 Tele.. 60-3321 hg@upb.de IV. Design Pattern IV.1 Introduction IV.2 Example: WYSIWYG Editor Lexi IV.3 Creational

More information

Object-oriented Software Design Patterns

Object-oriented Software Design Patterns Object-oriented Software Design Patterns Concepts and Examples Marcelo Vinícius Cysneiros Aragão marcelovca90@inatel.br Topics What are design patterns? Benefits of using design patterns Categories and

More information

Pro Objective-C Design Patterns for ios

Pro Objective-C Design Patterns for ios Pro Objective-C Design Patterns for ios Carlo Chung Contents Contents at a Glance About the Author About the Technical Reviewer Acknowledgments Preface x xi xii xiii Part I: Getting Your Feet Wet 1 Chapter

More information

COURSE 4 DESIGN PATTERNS

COURSE 4 DESIGN PATTERNS COURSE 4 DESIGN PATTERNS PREVIOUS COURSE Creational Patterns Factory Method defines an interface for creating objects, but lets subclasses decide which classes to instantiate Abstract Factory provides

More information

UP Requirements. Software Design - Dr Eitan Hadar (c) Activities of greater emphasis in this book. UP Workflows. Business Modeling.

UP Requirements. Software Design - Dr Eitan Hadar (c) Activities of greater emphasis in this book. UP Workflows. Business Modeling. UP Requirements UP Workflows Business Modeling Requirements Analysis and Design Implementation Test Deployment Configuration & Change Management Project Management Environment Iterations Activities of

More information

Design Patterns in Python (Part 2)

Design Patterns in Python (Part 2) Design Patterns in Python (Part 2) by Jeff Rush Jeff Rush 1 of 13 Design Patterns in Python What is a Pattern? a proven solution to a common problem in a specific context describes a

More information

THOMAS LATOZA SWE 621 FALL 2018 DESIGN PATTERNS

THOMAS LATOZA SWE 621 FALL 2018 DESIGN PATTERNS THOMAS LATOZA SWE 621 FALL 2018 DESIGN PATTERNS LOGISTICS HW3 due today HW4 due in two weeks 2 IN CLASS EXERCISE What's a software design problem you've solved from an idea you learned from someone else?

More information