MSO Lecture 11. Wouter Swierstra (adapted by HP) October 23, 2017

Size: px
Start display at page:

Download "MSO Lecture 11. Wouter Swierstra (adapted by HP) October 23, 2017"

Transcription

1 1 MSO Lecture 11 Wouter Swierstra (adapted by HP) October 23, 2017

2 2 REVIEW Object oriented analysis: UP requirements use cases domain models GRASP principles Design patterns: Facade Adapter Bridge Strategy Abstract Factory

3 3 TODAY Object oriented analysis: The analysis matrix Design patterns: Recursion and the Decorator pattern The Model-View-Controller pattern The Observer pattern

4 4 BUT REALLY... What makes great code? Thinking in terms of responsibilities. Principles of good design: Favor aggregation over inheritance; Program to an interface not an implementation; Find what varies and encapsulate it. What is the process of software design?

5 5 ANALYSIS We ve seen different techniques for analyzing a problem domain: noun-verb analysis; commonality variability analysis. Today, we ll add one more tool to the toolbox: the analysis matrix.

6 VARIATIONS, VARIATIONS, VARIATIONS... 6

7 7 HANDLING VARIATION A lot of systems grow complex quickly because they need to handle a lot of special cases, variations, etc. Look out for examples the next time you fill in a tax form. This creates headaches for analysts. How can we design software that can handle this well?

8 8 THE ANALYSIS MATRIX 1. Identify the most important features in a particular scenario and organize them in a matrix. 2. Proceed through other scenarios, expanding the matrix as necessary. 3. Expand the analysis matrix with new concepts. 4. Use the rows to identify rules. 5. Use the columns to identify specific situations. 6. Identify design patterns from this analysis. 7. Develop a high-level design.

9 9 CASE STUDY: E-COMMERCE REQUIREMENTS Build a sales order system for Canada and the USA; Calculate freight based on the country we are in. Money will be handled in the country we are in. In the USA, tax will be calculated by state. Use US Postal rules for verifying addresses. In Canada, use FedEx for shipping and Government Sales Tax and Provincial Sales Tax.

10 10 IDENTIFY VARIATION We have one important distinction to make: When the customer is in the USA; When the customer is in Canada.

11 11 THE ANALYSIS MATRIX Start identifying the key features of one case: selling in the USA. US Sales Calculate freight Use UPS rates Verify address Use US postal rules Calculate tax Use state and local taxes Currency US Dollars

12 12 GROWING THE MATRIX Calculate freight Verify address Calculate tax Currency US Sales Use UPS rates Use US postal rules Use state and local taxes US Dollars Canadian Sales

13 13 GROWING THE MATRIX US Sales Canadian Sales Calculate freight Use UPS rates Verify address Use US postal rules Calculate tax Use state and local taxes Currency US Dollars Canadian Dollars

14 14 GROWING THE MATRIX US Sales Canadian Sales Calculate freight Use UPS rates Use FedEx rates Verify address Use US postal rules Canadian postal rules Calculate tax Use state and local taxes Use GST and PST Currency US Dollars Canadian Dollars

15 15 IN PRACTICE... It does not always play out so nicely... But that is a Good Thing! The analysis matrix can help point out gaps in the requirements. For example, in Canada the maximum weight FedEx will handle is 31.5 kg now you can ask your customer if there is a maximum weight for US shipments (they probably forgot to mention this).

16 16 EXTENDING THE DESIGN As you add new countries, you may uncover further variation, adding new rows: For instance, shipping to the Netherlands means: handling a new currency; but also handling a different date format.

17 17 WORKING WITH CUSTOMERS Customers know the problem domain extremely well. They do not think like Computer Scientists or Information Scientists they talk about specific examples. When they say always, they mean usually. When they say never, they mean rarely. Organizing information in this matrix can guide customer interaction.

18 18 IDENTIFYING RULES The different rows correspond to different implementations of some general concept: calculating shipping rates; formatting dates. Implementing this variation can be done in different ways: the class itself may be responsible for the variation, such as formatting Dates; you may want to introduce a design pattern (such as the Strategy, Bridge, or Decorator) to encapsulate the variation.

19 19 ISN T THIS THE SAME AS CVA? Yes and no. Both a CVA and Analysis matrix identify variation in your domain. The focus is very different: A CVA is domain-model driven and classifies conceptual classes according to their commonality/variation. An analysis matrix is use-case driven and structures the available information and helps identifies missing information. Their closely related, but complementary techniques. So far for the Analysis matrix.

20 EVER HEARD OF RECURSION? 20

21 21 TOWARDS THE DECORATOR PATTERN pannenkoek pannenkoek pannenkoek pannenkoek pannenkoek stroop bosbessenjam spek kaas ui

22 22 INNOVATION & CHANGING REQUIREMENTS pannenkoek stroop pannenkoek bosbessenjam pannenkoek spek pannenkoek kaas pannenkoek ui pannenkoek champignons pannenkoek spek & kaas pannenkoek spek & stroop pannenkoek ui & champignons pannenkoek spek & kaas & stroop speltpannenkoek stroop speltpannenkoek bosbessenjam......

23 23 TOWARDS THE DECORATOR PATTERN Suppose we have our SalesOrder class, capable of handling different tax calculations. SalesOrder + process() + printreceipt() CalcTax calculatetax(price : double) NLTax UKTax (You should recognize the Strategy pattern.)

24 24 CHANGING REQUIREMENTS... But now suppose that we need to print receipts as well SalesOrder + process() + printreceipt() Receipt + print() CalcTax calculatetax(price : double) NLTax UKTax

25 25 RECEIPT PRINTING Each sales receipt may be decorated with additional information in the header and footer: address and tax information; customer loyalty points, if applicable; import/export fees, if applicable; discount code for your next order, if applicable....

26 26 FIRST SOLUTION SalesOrder + process() + printreceipt() Receipt + print() CalcTax calculatetax(price : double) Header + print() Footer + print() NLTax UKTax

27 27 CRITIQUE This will work but: you need to include a lot of switches in the Header and Footer classes to decide what to print (bad code smell); you will mix the code that prints the headers with the control code, deciding which headers to print (weak cohesion); Can we do better?

28 28 USE THE STRATEGY PATTERN We can use the Strategy pattern to print the header and footer information. But what if we want to print more than one header and/or footer at a time? we need to reorder the headers and/or footers? The Strategy pattern may not be the best solution.

29 29 THE DECORATOR PATTERN The Gang of Four describe the intent of the decorator pattern as: Attach additional responsibilities to an object dynamically. Decorators provide a flexible alternative for extending functionality.

30 30 A CHAIN OF DECORATORS Intuitively, you can think of decorators as a chain of Decorator objects that all add some new functionality to concrete component. Decorator A Decorator B Decorator C Concrete Component Example: stroop kaas spek speltpannenkoek How can we organize this in a design?

31 31 THE DECORATOR PATTERN Component operation() Concrete operation() Decorator operation() Concrete DecoratorA operation() Concrete DecoratorB operation()

32 This Decorator class has a recursive component; It uses a two-level deep inheritance hierarchy for good reason! 32 THE DECORATOR PATTERN Component operation() Concrete operation() Decorator operation() Concrete DecoratorA operation() Concrete DecoratorB operation()

33 33 APPLYING THE DECORATOR PATTERN The sales order example: print() Receipt BaseReceipt print() Receipt Decorator print() LoyaltyPoints Decorator print() ExportFees Decorator print()

34 KEEP ORDER! Note that you can call the next receipt(decorator) before or after executing the component. class LoyaltyPointsDecorator : ReceiptDecorator { public void print() { Console.WriteLine("10 points earned"); receipt.print(); } } The order we choose determines whether we get headers or footers. Question: is LPD a header or a footer? 34

35 35 ORDERING EXAMPLE - I To produce: Header1 Base receipt Footer1 We assemble the following receipt: new Header1(new Footer1(new BaseReceipt())); Or equivalently: new Footer1(new Header1(new BaseReceipt()));

36 ORDERING EXAMPLE - II To produce: Header1 Header2 Base receipt Footer1 We assemble the following receipt: new Header1 (new Header2 (new Footer1 (new BaseReceipt()))); Order matters! 36

37 37 ORDERING EXAMPLE - II new Header1 (new Header2 (new Footer1 (new BaseReceipt()))); Order matters! But beware: the creation order is important for the processing order of the headers w.r.t. each other the creation order is important for the processing order of the footers w.r.t. each other the order of the recursive method call determines whether it is a header or a footer

38 38 DECORATORS IN OO LANGUAGES I/O in C# and Java uses lots of decorators: C# defines an abstract Stream class with methods like BeginRead and Close; There are concrete instances for writing to a file, network socket, etc. Using decorators, you can define your own instance that: decrypts the data; zips the data; buffers data; converts the data;...

39 DECORATOR REVIEW Intent: Attach additional responsibilities to an object dynamically. Problem: The object you want to use does the basic functions you require. However, you may need to add some additional functionality to the the object, occurring before or after the object s basic functionality. Solution: Allows for extending the functionality without resorting to subclassing. Participants: The ConcreteComponent is the base class, that is extended with Decorators. Their common abstract superclass, Component, defines the interface for both the ConcreteComponent and Decorator classes. Consequences: The functionality that needs to be added should be done in (small) Decorator objects. These decorator objects can then be dynamically wrapped around the ConcreteComponent as necessary. 39

40 40 SOFTWARE ARCHITECTURE DEFINITION According to Wikipedia: Software architecture describes the high-level structure of a software system.

41 41 SOFTWARE ARCHITECTURE DEFINITION Software architecture encompasses the set of significant decisions about the organization of a software system including the selection of the structural elements and their interfaces by which the system is composed; behavior as specified in collaboration among those elements; composition of these structural and behavioral elements into larger subsystems; and an architectural style that guides this organization. Software architecture also involves functionality, usability, resilience, performance, reuse, comprehensibility, economic and technology constraints, tradeoffs and aesthetic concerns. (According to Kruchten, Booch, Bittner, and Reitman)

42 42 SOFTWARE ARCHITECTURE DEFINITION The highest-level breakdown of a system into its parts; the decisions that are hard to change; there are multiple architectures in a system; what is architecturally significant can change over a system s lifetime; and, in the end, architecture boils down to whatever the important stuff is. (According to Fowler, emphasis is mine)

43 43 ARCHITECTURAL DECISIONS How will the users be using the application? Where is data stored? How will the application be deployed? How will it be maintained?

44 44 ARCHITECTURAL PATTERNS Just as we have seen design patterns, there are numerous architectural patterns: Component-based Data-centric Event-driven (or Implicit invocation) Layered Peer-to-peer Pipes and filters Plug-ins

45 45 ARCHITECTURAL PATTERNS We will mentionone pattern that is more architectural in flavour than many of the design patterns we have seen so far, Model-View-Controller. Why do this? It is very useful for the final lab project. It helps you understand that patterns appear on different levels during software design. It might motivate you to study such patterns further. (MVC is actually discussed in the first pages of the Gang of Four book it s a classic pattern that predates many of the design patterns we ve seen so far.)

46 46 PROBLEM: A BOARD AND PIECES GAME Suppose you need to (re)implement a board and pieces game. What do you need to do? Logic for handling the moves; Graphics for the board and pieces; Interaction with the users. How should you assign these aspects to classes?

47 47 MODEL-VIEW-CONTROLLER The MVC is a triple of classes or components: The Model is responsible for storing the data; The View is responsible for visualizing data; The Controller is responsible for user interaction.

48 48 MODEL-VIEW-CONTROLLER ON THE WEB If you re familiar with webprogramming, you may find the following analogy useful: The Model is the data in an HTML page The View is the CSS file describing how it should be displayed The Controller is your browser that lets you view and navigate a webpage

49 49 MODEL-VIEW-CONTROLLER IN A DATABASE APPLICATION The Model is the database schema The View defines the GUI s for data entry and displaying query results The Controller defines the control flow and assembles/launches the SQL code

50 50 MODEL-VIEW-CONTROLLER initiate operation Model report events report events read data Controller update view send events View (This is not an UML diagram!)

51 51 WHY USE MVC? Strong cohesion responsibilities are clear. Decoupled different responsibilities: Allows for multiple views of the same data think of Excel! or completely different controllers. or change the way a view responds to the controller. Makes communication clear. Most of the domain logic should be in the Model. Exercise: Have a look at some of the code examples from IMP, GP, MOP, such as the calculator, TickTick or the drawing program. Can you recognize MVC structures?

52 52 COMMUNICATION How do the Model, View, and Controller communicate? When a new piece is placed in Reversi, how does the Model get updated? They are good candidates for using the Observer pattern.

53 53 OBSERVER PATTERN: CASE STUDY Suppose I get yet another new requirement for my online webstore. Whenever a new customer registers, we should: send a welcome to the customer verify the customer s address with the post office update our data base...

54 54 OBSERVER PATTERN: CASE STUDY We could hard-code this: class Customer { public void addcustomer() { server.welcomecustomer(); postoffice.verifyaddress(); database.addcustomer(); } } Doesn t seem very cohesive..., but it can get even worse.

55 OBSERVER PATTERN: GAMES Alternatively, what if you re writing a simple mobile game with a bunch of achievements that can be unlocked: when you defeat 100 enemies; when you die 10 times; when you have scored 1 million points;... Who checks when you earn an achievement? You want to keep the achievement checks separate from the main game code; But when certain events happen (enemy defeated, death, etc.) you may want to inform another class to check whether a new badge has been earned. How can you set up this communication effectively? 55

56 56 OBSERVER PATTERN: INTENT To define a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated. It s also known as the Publish-Subscribe model or Dependents.

57 57 TERMINOLOGY ISSUES: BOOK VS. C# IOBSERVER update() corresponds to Notify() attach() corresponds to Register() detach() corresponds to UnRegister() The terms update(), attach(), detach() are used in the book, where the authors define their own interface. The equivalent terms Notify(), Register(), UnRegister() match the C#-interface.

58 GENERAL OBSERVER PATTERN 58

59 59 STEP 1: ESTABLISH A COMMON INTERFACE In order to treat all the interested objects, or Observers, we need to establish a common interface. This could be using subclasses, but typically you may want to use an interface. C# has a special IObserver interface for precisely this purpose: public interface IObserver { void Notify(object anobject); } In our example, the server and post office would need to define Notify methods.

60 STEP 1: ESTABLISH A COMMON INTERFACE public interface IObserver { void Notify(object anobject); }... class PostOffice : IObserver... void Notify (Customer mycustomer) // do the required stuff here In our example, the server and post office would need to define Notify methods. 60

61 61 STEP 2: REGISTER THE OBSERVERS Let anyone interested in knowing about new customers register themselves. To do that, we add two methods to the Customer class, implementing this interface: public interface IObservable { void Register(IObserver anobserver); void UnRegister(IObserver anobserver); } Now anyone interested in new customers can Register.

62 62 STEP 3: NOTIFICATION Now when a new customer is added, we can notify any observers interested in that event: void notifyobservers () { foreach(iobserver anobserver in myobservers) { anobserver.notify(anobject); } } This could be that a new customer is registered, but also, for example, that an existing customer changes address.

63 63 STEP 4: EXPOSING FURTHER INFORMATION Perhaps the observers need further information about the Customers. You may want to revisit your design and make sure they have access to the necessary information, like addresses.

64 64 PITFALLS The Observer pattern is useful in when the list of Observers can vary: not all requirements are known yet; the observers change dynamically;... Otherwise, it adds unneccessary overhead.

65 65 MATERIAL COVERED Design Patterns explained. Chapter Model-view-controller.

MSO Lecture 11. Wouter Swierstra. October 15, 2015

MSO Lecture 11. Wouter Swierstra. October 15, 2015 1 MSO Lecture 11 Wouter Swierstra October 15, 2015 2 REVIEW Object oriented analysis: RUP; requirements; use cases; domain models; GRASP principles; Design patterns: Facade Bridge Strategy Abstract Factory...

More information

MSO Lecture 6. Wouter Swierstra (adapted by HP) September 28, 2017

MSO Lecture 6. Wouter Swierstra (adapted by HP) September 28, 2017 1 MSO Lecture 6 Wouter Swierstra (adapted by HP) September 28, 2017 2 LAST LECTURE Case study: CAD/CAM system What are design patterns? Why are they important? What are the Facade and Adapter patterns?

More information

MSO Lecture 6. Wouter Swierstra. September 24, 2015

MSO Lecture 6. Wouter Swierstra. September 24, 2015 1 MSO Lecture 6 Wouter Swierstra September 24, 2015 2 LAST LECTURE Case study: CAD/CAM system What are design patterns? Why are they important? What are the Facade and Adapter patterns? 3 THIS LECTURE

More information

MSO Lecture 12. Wouter Swierstra (adapted by HP) October 26, 2017

MSO Lecture 12. Wouter Swierstra (adapted by HP) October 26, 2017 1 MSO Lecture 12 Wouter Swierstra (adapted by HP) October 26, 2017 2 LAST LECTURE Analysis matrix; Decorator pattern; Model-View-Controller; Observer pattern. 3 THIS LECTURE How to create objects 4 CATEGORIES

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

RDD and Strategy Pa.ern

RDD and Strategy Pa.ern RDD and Strategy Pa.ern CSCI 3132 Summer 2011 1 OO So1ware Design The tradi7onal view of objects is that they are data with methods. Smart Data. But, it is be.er to think of them as en##es that have responsibili#es.

More information

Last Lecture. Lecture 17: Design Patterns (part 2) Kenneth M. Anderson Object-Oriented Analysis and Design CSCI 4448/ Spring Semester, 2005

Last Lecture. Lecture 17: Design Patterns (part 2) Kenneth M. Anderson Object-Oriented Analysis and Design CSCI 4448/ Spring Semester, 2005 1 Lecture 17: Design Patterns (part 2) Kenneth M. Anderson Object-Oriented Analysis and Design CSCI 4448/6448 - Spring Semester, 2005 2 Last Lecture Design Patterns Background and Core Concepts Examples

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

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

The Design Patterns Matrix From Analysis to Implementation

The Design Patterns Matrix From Analysis to Implementation The Design Patterns Matrix From Analysis to Implementation This is an excerpt from Shalloway, Alan and James R. Trott. Design Patterns Explained: A New Perspective for Object-Oriented Design. Addison-Wesley

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

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

MSO Object Creation Singleton & Object Pool

MSO Object Creation Singleton & Object Pool MSO Object Creation Singleton & Object Pool Wouter Swierstra & Hans Philippi October 25, 2018 Object Creation: Singleton & Object Pool 1 / 37 This lecture How to create objects The Singleton Pattern The

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

Index Shalloway rev.qrk 9/21/04 5:54 PM Page 419. Index

Index Shalloway rev.qrk 9/21/04 5:54 PM Page 419. Index Index Shalloway rev.qrk 9/21/04 5:54 PM Page 419 Index A Abandon (by) ship (date)!, 140 Abstract class type, 21 Abstract classes, 19, 22, 29 and common and variability analysis, 127 130 interfaces vs.,

More information

Common Architectural Styles & Patterns

Common Architectural Styles & Patterns Common Architectural Styles & Patterns some we ve already kind of discussed model view controller blackboard client/server layered pipe-and-filter Lots of ways to classify all these Application Domain

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

CPS122 Lecture: Design Patterns Last revised March 20, 2012

CPS122 Lecture: Design Patterns Last revised March 20, 2012 CPS122 Lecture: Design Patterns Last revised March 20, 2012 Objectives 1. To introduce and illustrate the idea of design patterns 2. To introduce some key design patterns students have used or will use:

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

CHAPTER 9 DESIGN ENGINEERING. Overview

CHAPTER 9 DESIGN ENGINEERING. Overview CHAPTER 9 DESIGN ENGINEERING Overview A software design is a meaningful engineering representation of some software product that is to be built. Designers must strive to acquire a repertoire of alternative

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

Design Patterns Revisited

Design Patterns Revisited CSC 7322 : Object Oriented Development J Paul Gibson, A207 paul.gibson@int-edu.eu http://www-public.it-sudparis.eu/~gibson/teaching/csc7322/ Design Patterns Revisited /~gibson/teaching/csc7322/l13-designpatterns-2.pdf

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

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

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

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

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

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

CS211 Lecture: Design Patterns Last revised November 30, 2007

CS211 Lecture: Design Patterns Last revised November 30, 2007 CS211 Lecture: Design Patterns Last revised November 30, 2007 Objectives 1. To introduce and illustrate the idea of design patterns 2. To introduce some key design patterns students have used or will use:

More information

Principles of Software Construction: Objects, Design, and Concurrency. Assigning Responsibilities to Objects. toad. Jonathan Aldrich Charlie Garrod

Principles of Software Construction: Objects, Design, and Concurrency. Assigning Responsibilities to Objects. toad. Jonathan Aldrich Charlie Garrod Principles of Software Construction: Objects, Design, and Concurrency Assigning Responsibilities to Objects toad Fall 2014 Jonathan Aldrich Charlie Garrod School of Computer Science Key concepts from Thursday

More information

CS342: Software Design. November 21, 2017

CS342: Software Design. November 21, 2017 CS342: Software Design November 21, 2017 Runnable interface: create threading object Thread is a flow of control within a program Thread vs. process All execution in Java is associated with a Thread object.

More information

Design Patterns Design patterns advantages:

Design Patterns Design patterns advantages: Design Patterns Designing object-oriented software is hard, and designing reusable object oriented software is even harder. You must find pertinent objects factor them into classes at the right granularity

More information

Customize. Building a Customer Portal Using Business Portal. Microsoft Dynamics GP. White Paper

Customize. Building a Customer Portal Using Business Portal. Microsoft Dynamics GP. White Paper Customize Microsoft Dynamics GP Building a Customer Portal Using Business Portal White Paper Helps you implement a customer portal and create web pages and web parts specifically designed for your customers.

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

Agile Architecture. The Why, the What and the How

Agile Architecture. The Why, the What and the How Agile Architecture The Why, the What and the How Copyright Net Objectives, Inc. All Rights Reserved 2 Product Portfolio Management Product Management Lean for Executives SAFe for Executives Scaled Agile

More information

CPSC 310 Software Engineering. Lecture 11. Design Patterns

CPSC 310 Software Engineering. Lecture 11. Design Patterns CPSC 310 Software Engineering Lecture 11 Design Patterns Learning Goals Understand what are design patterns, their benefits and their drawbacks For at least the following design patterns: Singleton, Observer,

More information

Application Architectures, Design Patterns

Application Architectures, Design Patterns Application Architectures, Design Patterns Martin Ledvinka martin.ledvinka@fel.cvut.cz Winter Term 2017 Martin Ledvinka (martin.ledvinka@fel.cvut.cz) Application Architectures, Design Patterns Winter Term

More information

Lecture 4: Design Concepts For Responsibility- Driven Design Kenneth M. Anderson January 20, 2005

Lecture 4: Design Concepts For Responsibility- Driven Design Kenneth M. Anderson January 20, 2005 Lecture 4: Design Concepts For Responsibility- Driven Design Kenneth M. Anderson 1 of 25 Introduction Chapter 1 of Object Design covers topics that aid understanding of Responsibility-Driven Design Object

More information

Design Patterns. CSC207 Fall 2017

Design Patterns. CSC207 Fall 2017 Design Patterns CSC207 Fall 2017 Design Patterns A design pattern is a general description of the solution to a well-established problem using an arrangement of classes and objects. Patterns describe the

More information

1 Software Architecture

1 Software Architecture Some buzzwords and acronyms for today Software architecture Design pattern Separation of concerns Single responsibility principle Keep it simple, stupid (KISS) Don t repeat yourself (DRY) Don t talk to

More information

From Design Patterns: Elements of Reusable Object Oriented Software. Read the sections corresponding to patterns covered in the following slides.

From Design Patterns: Elements of Reusable Object Oriented Software. Read the sections corresponding to patterns covered in the following slides. From Design Patterns: Elements of Reusable Object Oriented Software Read the sections corresponding to patterns covered in the following slides. DESIGN PRINCIPLES Modularity Cohesion Coupling Separation

More information

Plan. Design principles: laughing in the face of change. What kind of change? What are we trying to achieve?

Plan. Design principles: laughing in the face of change. What kind of change? What are we trying to achieve? Plan Design principles: laughing in the face of change Perdita Stevens School of Informatics University of Edinburgh What are we trying to achieve? Review: Design principles you know from Inf2C-SE Going

More information

Design Patterns. CSC207 Winter 2017

Design Patterns. CSC207 Winter 2017 Design Patterns CSC207 Winter 2017 Design Patterns A design pattern is a general description of the solution to a well-established problem using an arrangement of classes and objects. Patterns describe

More information

CPS122 Lecture: Design Patterns Last revised March 7, 2017

CPS122 Lecture: Design Patterns Last revised March 7, 2017 CPS122 Lecture: Design Patterns Last revised March 7, 2017 Objectives 1. To introduce and illustrate the idea of design patterns 2. To introduce some key design patterns students have used or will use:

More information

Design Patterns #3. Reid Holmes. Material and some slide content from: - GoF Design Patterns Book - Head First Design Patterns

Design Patterns #3. Reid Holmes. Material and some slide content from: - GoF Design Patterns Book - Head First Design Patterns Material and some slide content from: - GoF Design Patterns Book - Head First Design Patterns Design Patterns #3 Reid Holmes Lecture 16 - Thursday November 15 2011. GoF design patterns $ %!!!! $ "! # &

More information

Design Patterns. Gunnar Gotshalks A4-1

Design Patterns. Gunnar Gotshalks A4-1 Design Patterns A4-1 On Design Patterns A design pattern systematically names, explains and evaluates an important and recurring design problem and its solution Good designers know not to solve every problem

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

Inheritance. EEC 521: Software Engineering. Dealing with Change. Polymorphism. Software Design. Changing requirements Code needs to be flexible

Inheritance. EEC 521: Software Engineering. Dealing with Change. Polymorphism. Software Design. Changing requirements Code needs to be flexible Inheritance EEC 521: Software Engineering Software Design Design Patterns: Decoupling Dependencies 10/15/09 EEC 521: Software Engineering 1 Inheritance is the mechanism by which one class can acquire properties/responsibilities

More information

MSO Lecture 1. Wouter Swierstra (adapted by HP) September 11, 2017

MSO Lecture 1. Wouter Swierstra (adapted by HP) September 11, 2017 1 MSO Lecture 1 Wouter Swierstra (adapted by HP) September 11, 2017 So you think you can program... 2 From nrc.nl 3 Question: why do ICT-projects fail so often? 4 5 Question: why do ICT-projects fail so

More information

More on Design. CSCI 5828: Foundations of Software Engineering Lecture 23 Kenneth M. Anderson

More on Design. CSCI 5828: Foundations of Software Engineering Lecture 23 Kenneth M. Anderson More on Design CSCI 5828: Foundations of Software Engineering Lecture 23 Kenneth M. Anderson Outline Additional Design-Related Topics Design Patterns Singleton Strategy Model View Controller Design by

More information

LABORATORY 1 REVISION

LABORATORY 1 REVISION UTCN Computer Science Department Software Design 2012/2013 LABORATORY 1 REVISION ================================================================== I. UML Revision This section focuses on reviewing the

More information

GRASP Design Patterns A.A. 2018/2019

GRASP Design Patterns A.A. 2018/2019 GRASP Design Patterns A.A. 2018/2019 Objectives Introducing design patterns Introduzione ai design pattern Designing objects and responsibilities GRASP design patterns A long corridor A passage room Does

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

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

Foundations of Software Engineering Design Patterns -- Introduction

Foundations of Software Engineering Design Patterns -- Introduction Foundations of Software Engineering Design Patterns -- Introduction Fall 2016 Department of Computer Science Ben-Gurion university Based on slides of: Nurit Gal-oz, Department of Computer Science Ben-Gurion

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

CS 520/620 Advanced Software Engineering Spring February 11, 2016

CS 520/620 Advanced Software Engineering Spring February 11, 2016 CS 520/620 Advanced Software Engineering Spring 2016 February 11, 2016 Recap How to recognize a bad design? How to come up with a good design? Separation of concerns. Consider expected extensions. Design

More information

3 Product Management Anti-Patterns by Thomas Schranz

3 Product Management Anti-Patterns by Thomas Schranz 3 Product Management Anti-Patterns by Thomas Schranz News Read above article, it s good and short! October 30, 2014 2 / 3 News Read above article, it s good and short! Grading: Added explanation about

More information

Responsibilities. Using several specific design principles to guide OO design decisions.

Responsibilities. Using several specific design principles to guide OO design decisions. Designing Objects with Responsibilities Using several specific design principles to guide OO design decisions. Challenge Old-school advice on OOD After identifying i your requirements and creating a domain

More information

Design. Eric McCreath

Design. Eric McCreath Design Eric McCreath 2 Good Design As you move from Idea to Implementation good design plays a key part in making software robust, maintainable, and flexible. Good design is difficult It is easy to overcomplicate

More information

We will talk about Alt-Tab from the usability perspective. Think about: - Is it learnable? - Is it efficient? - What about errors and safety?

We will talk about Alt-Tab from the usability perspective. Think about: - Is it learnable? - Is it efficient? - What about errors and safety? 1 This lecture s candidate for the Hall of Fame & Shame is the Alt-Tab window switching interface in Microsoft Windows. This interface has been copied by a number of desktop systems, including KDE, Gnome,

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

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

CPS122 Lecture: Design Patterns Last revised April 22, 2010

CPS122 Lecture: Design Patterns Last revised April 22, 2010 CPS122 Lecture: Design Patterns Last revised April 22, 2010 Objectives 1. To introduce and illustrate the idea of design patterns 2. To introduce some key design patterns students have used or will use:

More information

Architectural Blueprint The 4+1 View Model of Software Architecture. Philippe Kruchten

Architectural Blueprint The 4+1 View Model of Software Architecture. Philippe Kruchten Architectural Blueprint The 4+1 View Model of Software Architecture Philippe Kruchten Model What is a model? simplified abstract representation information exchange standardization principals (involved)

More information

What is a Pattern? Lecture 40: Design Patterns. Elements of Design Patterns. What are design patterns?

What is a Pattern? Lecture 40: Design Patterns. Elements of Design Patterns. What are design patterns? What is a Pattern? Lecture 40: Design Patterns CS 62 Fall 2017 Kim Bruce & Alexandra Papoutsaki "Each pattern describes a problem which occurs over and over again in our environment, and then describes

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

Architectural Blueprint

Architectural Blueprint IMPORTANT NOTICE TO STUDENTS These slides are NOT to be used as a replacement for student notes. These slides are sometimes vague and incomplete on purpose to spark a class discussion Architectural Blueprint

More information

Design Patterns. Observations. Electrical Engineering Patterns. Mechanical Engineering Patterns

Design Patterns. Observations. Electrical Engineering Patterns. Mechanical Engineering Patterns Introduction o to Patterns and Design Patterns Dept. of Computer Science Baylor University Some slides adapted from slides by R. France and B. Tekinerdogan Observations Engineering=Problem Solving Many

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

MSO Lecture Design by Contract"

MSO Lecture Design by Contract 1 MSO Lecture Design by Contract" Wouter Swierstra (adapted by HP, AL) October 8, 2018 2 MSO SO FAR Recap Abstract Classes UP & Requirements Analysis & UML OO & GRASP principles Design Patterns (Facade,

More information

EINDHOVEN UNIVERSITY OF TECHNOLOGY

EINDHOVEN UNIVERSITY OF TECHNOLOGY EINDHOVEN UNIVERSITY OF TECHNOLOGY Department of Mathematics & Computer Science Exam Programming Methods, 2IP15, Wednesday 17 April 2013, 09:00 12:00 TU/e THIS IS THE EXAMINER S COPY WITH (POSSIBLY INCOMPLETE)

More information

Design Patterns. CSC207 Fall 2017

Design Patterns. CSC207 Fall 2017 Design Patterns CSC207 Fall 2017 Design Patterns A design pattern is a general description of the solution to a well-established problem using an arrangement of classes and objects. Patterns describe the

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

Object-Oriented Design

Object-Oriented Design Object-Oriented Design Lecture 14: Design Workflow Department of Computer Engineering Sharif University of Technology 1 UP iterations and workflow Workflows Requirements Analysis Phases Inception Elaboration

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

Enterprise Integration Patterns: Designing, Building, and Deploying Messaging Solutions

Enterprise Integration Patterns: Designing, Building, and Deploying Messaging Solutions Enterprise Integration Patterns: Designing, Building, and Deploying Messaging Solutions Chapter 1: Solving Integration Problems Using Patterns 2 Introduction The Need for Integration Integration Challenges

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

Plan. Design principles: laughing in the face of change. What kind of change? What are we trying to achieve?

Plan. Design principles: laughing in the face of change. What kind of change? What are we trying to achieve? Plan Design principles: laughing in the face of change Perdita Stevens School of Informatics University of Edinburgh What are we trying to achieve? Review: Design principles you know from Inf2C-SE Going

More information

As a programmer, you know how easy it can be to get lost in the details

As a programmer, you know how easy it can be to get lost in the details Chapter 1 Congratulations, Your Problem Has Already Been Solved In This Chapter Introducing design patterns Knowing how design patterns can help Extending object-oriented programming Taking a look at some

More information

Last Lecture. Lecture 26: Design Patterns (part 2) State. Goals of Lecture. Design Patterns

Last Lecture. Lecture 26: Design Patterns (part 2) State. Goals of Lecture. Design Patterns Lecture 26: Design Patterns (part 2) Kenneth M. Anderson Object-Oriented Analysis and Design CSCI 6448 - Spring Semester, 2003 Last Lecture Design Patterns Background and Core Concepts Examples Singleton,

More information

Chapter 12 (revised by JAS)

Chapter 12 (revised by JAS) Chapter 12 (revised by JAS) Pattern-Based Design Slide Set to accompany Software Engineering: A Practitionerʼs Approach, 7/e by Roger S. Pressman Slides copyright 1996, 2001, 2005, 2009 by Roger S. Pressman

More information

Applying the Observer Design Pattern

Applying the Observer Design Pattern Applying the Observer Design Pattern Trenton Computer Festival Professional Seminars Michael P. Redlich (908) 730-3416 michael.p.redlich@exxonmobil.com About Myself Degree B.S. in Computer Science Rutgers

More information

Object-Oriented Thinking

Object-Oriented Thinking Chapter 9 Object-Oriented Thinking Smalltalk is one of the pure Object-Oriented (OO) languages. Unlike C++, which makes it very easy to write procedural code (ie, use C++ as a better C), Smalltalk makes

More information

CSC207H: Software Design Lecture 6

CSC207H: Software Design Lecture 6 CSC207H: Software Design Lecture 6 Wael Aboelsaadat wael@cs.toronto.edu http://ccnet.utoronto.ca/20075/csc207h1y/ Office: BA 4261 Office hours: R 5-7 Acknowledgement: These slides are based on material

More information

CS211 Lecture: Design Quality; Cohesion and Coupling; Packages

CS211 Lecture: Design Quality; Cohesion and Coupling; Packages CS211 Lecture: Design Quality; Cohesion and Coupling; Packages Objectives: Last revised October 4, 2004 1. To introduce the notion of design quality, tradeoffs, and some principles of quality design 2.

More information

CAS 703 Software Design

CAS 703 Software Design Dr. Ridha Khedri Department of Computing and Software, McMaster University Canada L8S 4L7, Hamilton, Ontario Acknowledgments: Material based on Software by Tao et al. (Chapters 9 and 10) (SOA) 1 Interaction

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

Welcome to Design Patterns! For syllabus, course specifics, assignments, etc., please see Canvas

Welcome to Design Patterns! For syllabus, course specifics, assignments, etc., please see Canvas Welcome to Design Patterns! For syllabus, course specifics, assignments, etc., please see Canvas What is this class about? While this class is called Design Patterns, there are many other items of critical

More information

Goals of Lecture. Lecture 27: OO Design Patterns. Pattern Resources. Design Patterns. Cover OO Design Patterns. Pattern Languages of Programming

Goals of Lecture. Lecture 27: OO Design Patterns. Pattern Resources. Design Patterns. Cover OO Design Patterns. Pattern Languages of Programming Goals of Lecture Lecture 27: OO Design Patterns Cover OO Design Patterns Background Examples Kenneth M. Anderson Object-Oriented Analysis and Design CSCI 6448 - Spring Semester, 2001 April 24, 2001 Kenneth

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

Object-Oriented Design

Object-Oriented Design Object-Oriented Design Lecturer: Raman Ramsin Lecture 20: GoF Design Patterns Creational 1 Software Patterns Software Patterns support reuse of software architecture and design. Patterns capture the static

More information

17. GRASP: Designing Objects with Responsibilities

17. GRASP: Designing Objects with Responsibilities 17. GRASP: Designing Objects with Responsibilities Objectives Learn to apply five of the GRASP principles or patterns for OOD. Dr. Ziad Kobti School of Computer Science University of Windsor Understanding

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

Foundations of object orientation

Foundations of object orientation Foreword Preface List of projects discussed in detail in this book Acknowledgments Part 1 Chapter 1 Chapter 2 Foundations of object orientation Objects and classes 1.1 Objects and classes 1.2 Creating

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

ADVANCED SOFTWARE DESIGN LECTURE 4 SOFTWARE ARCHITECTURE

ADVANCED SOFTWARE DESIGN LECTURE 4 SOFTWARE ARCHITECTURE ADVANCED SOFTWARE DESIGN LECTURE 4 SOFTWARE ARCHITECTURE Dave Clarke 1 THIS LECTURE At the end of this lecture you will know notations for expressing software architecture the design principles of cohesion

More information

Design Engineering. Overview

Design Engineering. Overview Design Engineering Overview What is software design? How to do it? Principles, concepts, and practices High-level design Low-level design N. Meng, B. Ryder 2 1 Design Engineering The process of making

More information

Patterns Architectural Styles Archetypes

Patterns Architectural Styles Archetypes Patterns Architectural Styles Archetypes Patterns The purpose of a pattern is to share a proven, widely applicable solution to a particular problem in a standard form that allows it to be easily reused.

More information

Writing your own Java I/O Decorator p. 102 Tools for your Design Toolbox p. 105 Exercise Solutions p. 106 The Factory Pattern Baking with OO

Writing your own Java I/O Decorator p. 102 Tools for your Design Toolbox p. 105 Exercise Solutions p. 106 The Factory Pattern Baking with OO Intro to Design Patterns Welcome to Design Patterns: Someone has already solved your problems The SimUDuck app p. 2 Joe thinks about inheritance... p. 5 How about an interface? p. 6 The one constant in

More information