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

Size: px
Start display at page:

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

Transcription

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

2 2 LAST LECTURE Analysis matrix; Decorator pattern; Model-View-Controller; Observer pattern.

3 3 THIS LECTURE How to create objects

4 4 CATEGORIES OF DESIGN PATTERNS The Gang of Four distinguish three categories of design patterns: Behavioural patterns characterize the way in which classes or objects interact or distribute responsibility. Observer, Strategy Structural patterns deal with the composition of classes or objects. Adapter, Bridge, Decorator Creational patterns are concerned with the creation of new objects. Abstract Factory (Shalloway and Trott also distinguish a decoupling category, which forms a subset of the behavioural patterns).

5 5 WHY WORRY ABOUT CREATION? A lot of the design we have focussed on so far in this course is concerned with figuring out how classes should work together, and how to encapsulate variation hiding implementation details. But if we hide implementation details behind an abstract class, who decides which concrete instances should be made?

6 6 FACTORIES Separating creation and usage leads to stronger cohesion. Separate two distinct tasks: Defining classes and how they work together Writing factories that instantiate the correct objects for the right situation.

7 7 NOT EVERYONE AGREES... Remember Larman s Creator GRASP principle: Assign class B the responsibility to create instances of a class A if A has a B object. This is a good guideline for simple situations, provided you are not programming to an interface. If you are, you may need to consider applying creational design patterns.

8 8 CREATION VS USE Shalloway and Trott say that an object should either: make and/or manage other objects; or it should use other objects. It should never do both. Following this rule leads to looser coupling.

9 9 USING OBJECTS "Program to an interface, not to an implementation" "Find what varies, and encapsulate it" Using Object AbstractClass Concrete ClassA Concrete ClassA

10 10 EXAMPLE: STRATEGY If the Context creates concrete strategies, it s breaking an abstraction barrier. Instead, we want to assign the responsibility for creation to another object.

11 11 FACTORY OBJECTS Compare figure 20-3 on page 352 of S&T.

12 12 USING VS CREATING OBJECTS The Factory can create values of type AbstractClass on request. It stores all the creational logic and creates a concrete object. Using objects means knowing only about the interface, not the implementation. The Factory objects should only know how to create concrete instances. They should not rely on the details of the abstract class/interface. We are free to add new concrete classes as necessary we know that the client objects should never inspect which concrete class they are using the Open-Closed principle!

13 13 SUMMARY Patterns add indirection (hide information behind an abstract class, move functionality to new classes,... ) This makes code more maintainable, but adds complexity. Factories and other creational patterns are designed to hide the complexity that patterns sometimes introduce.

14 14 THE SINGLETON PATTERN Factories can be used for more than just controlling which concrete instances to create. For instance, factories may implement constraints. The Singleton Pattern for example, can be used to guarantee that exactly one object exists of a particular type.

15 15 THE SINGLETON PATTERN Singleton - instance : Singleton - singletondata - Singleton() + static getinstance() + operation... + getdata

16 16 THE SINGLETON PATTERN public class Singleton { private static Singleton instance; private Singleton() {... } } public static Singleton getinstance() { if (instance == null) { instance = new Singleton(); } return instance; }

17 17 SINGLETON: EXAMPLE One example of a Singleton could be the CalcTax strategy for a specific country. Another example of a Singleton could be a logging service: Different objects want to be able to log a message. They want a single point of entry to send their logging requests we do not want to create new services for each request.

18 18 CAUTION! Singletons are not thread safe. If you have multiple threads trying to create a singleton at the same time, you may create two (or more) Singleton objects. Solution: The Double-Checked Locking Pattern addresses this. I will not cover it in this course.

19 19 MORE CAUTION! Singletons are a controversial pattern. The Singleton is regarded to be an over applied pattern - it is often not even needed. To decide whether a class is truly a singleton, you must ask yourself some questions: Will every application use this class exactly the same way? Will every application ever need only one instance of this class? (Rainsberger 2001) So much for singletons.

20 20 CASE STUDY: ELECTRONIC BANKING Today let s suppose we need to write software for online investment services, like alex.nl, that allow users: to browse their investment portfolio; to give orders for purchasing or selling stocks;... We will see that Factory tasks may be a bit more involving than just creating objects!

21 21 ARCHITECTURE Java Servlet CORBA C++ Middleware TCP/IP Mainframe

22 22 REQUIREMENTS The only way to communicate with the mainframe is through TCP/IP connections using a custom messaging protocol. The C++ (or C#, or...) middleware is responsible for verifying user orders, before they are executed by the mainframe.

23 23 EXAMPLE INTERACTION User logs in through their webbrowser. Middleware gets user ID and password. Reformats message in a format the mainframe can understand. Mainframe accepts the request and responds accordingly.

24 24 PERFORMANCE CONCERNS The middleware needs to handle requests from many, many people at the same time; We should aim to handle as many transactions as possible - aim to maximize throughput - and not worry about the time a single transaction needs.

25 25 DESIGN QUESTION How many TCP/IP connections should I use? 1 is too little all traffic goes over a single connection; 100 is too much the bandwidth available could not handle more than 20. This is a high-risk issue. The performance of the entire system can rely on it.

26 26 ISSUES INVOLVED Establish a single, robust TCP/IP connection. Determine the number of TCP/IP connections that are necessary. Establish a method to load balance the connections we don t want to route all traffic through a single connection, while the others idle. Handle errors on TCP/IP connections, as these can be unreliable. What to do first?

27 27 DESIGN CHOICE Start by establishing a single connection but don t forget that you will have to address these other issues soon. General strategy: insulate yourself from change, but anticipate new requirements.

28 28 CHOOSING THE CONNECTIONS We need to design the system so that we can easily change the number of connections used. So who is responsible for establishing the connections? Someone else. Find what varies and encapsulate it.

29 29 TCP/IP MANAGEMENT We need a class to manage the TCP/IP connections. Should this be the connection class itself?

30 30 TCP/IP MANAGEMENT Distinguish separate responsibilities: A Port class is responsible for communicating with the mainframe; A PortManager class is responsible for keeping track of the Ports.

31 31 HOW MANY? There should be multiple Port objects. The PortManager should be able to change the exact number easily. There should only be a single PortManager object otherwise we don t have control over how many connections are established exactly. Use the Singleton pattern!

32 32 FUNCTIONALITY The PortManager supports has the following methods and attributes: a private array of Port objects; GetInstanceOfPort() - which looks through the array to find an inactive port. If no port is inactive, it sleeps and retries. ReturnInstanceOfPort(Port release) - sets the status of the argument port to inactive.

33 33 USING PORTS Client code is now straightforward: 1. Ask the PortManager for a Port object; 2. Complete the transaction. 3. Release the Port to the PortManager. The client code does not need to know anything about how many ports are active, setting up connections, etc.

34 34 STRONG COHESION, LOOSE COUPLING This solution has strong cohesion and loose coupling the Port, Client, and PortManager classes all have a clear set of responsibilities. What happens when I need to add error handling?

35 35 ADDING ERROR HANDLING What happens when a connection goes down? 1. The Client code needs to request another Port; 2. The Port that went down should be closed; 3. The PortHandler may want to establish a new connection to replace the Port that want down. It is clear who is responsible for handling this exceptional scenario.

36 36 ARE WE DONE? If you re responsible for developing a system that handles millions of dollars worth of transactions, will you sleep easy at night?

37 37 ADD CHECKING Maybe we would sleep easier if the PortManager also checked the integrity of the connection. Every 15 (or so) minutes it should: 1. Check how many unanswered requests there are for a Port; 2. Query all the Ports to see if they are active or not; 3. Check how many Ports have run into an error. If any of these checks produces unexpected results, warning bells should go off.

38 38 EVEN BETTER... Don t stop there! It s not enough to know that a system is not failing. Perhaps you cannot detect connection problems, but people still are not able to use the website. Log successful transactions.

39 39 THE OBJECT POOL PATTERN Client 0..* 1 Uses * Reusable 0..* ReusablePool -ReusablePool() +getinstance() +acquirereusable() : Reusable +releasereusable(r : Reusable) +setsize(maxsize : int) 1 1 Note that getinstance() refers to the creation of a singleton ReusabePool.

40 40 THE OBJECT POOL PATTERN: LESSONS Factories are not just about instantiation.

41 41 TWO MORE PATTERNS Template Method Pattern Factory Method Pattern We will look see them working in an integrated way.

42 42 CASE STUDY: DATABASES The Template Method pattern can be very useful when a certain kind of computation has a lot of variation - it allows us to encapsulate this variation. preparequery(query1);... if (database == ORACLE) conn = formatoracleconnect(); else conn = formatsqlserverconnect(); if (database == ORACLE) res = formatoracleselect(conn, query1); else res = formatsqlserverselect(conn, query1); processresults(res);

43 43 CASE STUDY: DATABASES Suppose we need to write software that generates SQL queries on different databases (both Oracle and SQL Server). In principle the queries have the same structure: 1. Format the CONNECT command. 2. Send the database the CONNECT command. 3. Format the SELECT command. 4. Send the database the SELECT command. 5. Return the answer from the database.... but there is slight variation in the formatting procedures for the different database backends.

44 44 TEMPLATE METHOD: INTENT The Gang of Four define the intent of the Template Method Pattern as: Define the skeleton of an algorithm in an operation, deferring some steps to subclasses. Redefine the steps in an algorithm without changing the algorithm s structure. This sounds similar to our database problem...

45 45 TEMPLATE METHOD QueryControl Query Template + doquery() # formatconnect() # formatselect() Oracle Query Template # formatconnect() # formatselect() SQLServer Query Template # formatconnect() # formatselect()

46 46 WHERE THE MAGIC HAPPENS The QueryTemplate class defines the following method: public doquery(string q) {... c = formatconnect();... res = formatselect(c, q); processresults(res); } An abstract class (QueryTemplate) defines a public, concrete method (doquery), that itself calls abstract, protected methods (formatselect and formatconnect).

47 47 CODE-BASED CVA Template Methods are a great way to clean up duplicated methods, or fixing code that has been copy-pasted and edited. 1. Look for the common parts these go in the abstract class. 2. Look for the variation these go in the concrete instances.

48 48 TEMPLATE METHOD I Intent: Define the skeleton of an algorithm, deferring some steps to subclasses, making it possible to redefine some of the steps in the algorithm, without changing the algorithm s structure. Problem: There is a procedure or set of steps that is consistent at one level of detail, but individual steps may have different implementations. Solution: Allows for a definition of substeps that vary while maintaining a consistent basic process. Participants: The Template Method defines an abstract class with a concrete method, that uses abstract methods that need to be overridden.

49 49 TEMPLATE METHOD II Consequences: Templates provide a good platform for code reuse. They are also helpful in ensuring the required steps are implemented. Implementation: Template + TemplateMethod() # operation1() # operation2() Concrete Template A # operation1() # operation2() Concrete Template B # operation1() # operation2()

50 50 CREATION? In our case study, the Template Method pattern showed how to handle variation in database communication. An abstract QueryTemplate object hides implementation details. But who creates the associated database object?

51 51 ASSIGNING RESPONSIBILITY If the database creation varies between the two Template subclasses (for Oracle or SQL Server databases), the subclasses should be responsible.

52 52 QueryControl Query Template + doquery() # formatconnect() # formatselect() # makedatabase() Oracle Query Template # formatconnect() # formatselect() # makedatabase() SQLServer Query Template # formatconnect() # formatselect() # makedatabase()

53 53 WHAT DOES THIS ACHIEVE? The QueryTemplate class does not know which database is created. It just knows that all concrete derived classes will define a method to create a database object. The derived classes are responsible for the creation. This is called the Factory Method pattern, which is used heavily in C# collections libraries.

54 54 FACTORY METHOD: INTENT The Gang of Four define the intent of the Factory Method Pattern: Define an interface for creating an object, but let subclasses decide which class to instantiate. Factory Method lets a class defer instantiation to subclasses.

55 55 FACTORY METHOD Product Creator MakeProduct() Operation() Concrete Product Concrete Creator MakeProduct()

56 56 FACTORY METHOD Product Creator MakeProduct() Operation() Concrete Product Concrete Creator MakeProduct() Example: (book is vague on this issue) Creator <=> Query Template MakeProduct() <=> MakeDatabase() Operation() <=> logic in creation process

57 BACK TO SALESORDER AND CALCTAX Let us recall our Salesorder - CalcTax example. We applied the Strategy pattern. But the logic for choosing the concrete strategy object was still part of the Context. We could add a public method makecalctax(customer c) to the interface of Strategy. This way, we combine patterns Strategy and Factory Method. 57

58 58 OVERVIEW 1. Identifying objects based on responsibilities (CVA, Analysis matrix, noun-verb analysis, GRASP). 2. Deciding how to use these objects (design patterns). 3. Deciding how to manage these objects (factories).

59 59 PHILOSOPHY BEHIND FACTORIES Conceptually similar objects are often used in the same way. When creating these objects, there is some logic involved that decides to choose one specific concrete class. The using class should not know which specific concrete class it is using it should program to an interface, not an implementation. So if the using class cannot choose how to instantiate objects, someone must be responsible - enter Factories.

60 60 FACTORIES AND CHANGING REQUIREMENTS In practice most new requirements affect either the users of an object or system (or its internal implementation) or the logic controlling the choice of which objects to create It is much less common that both these things need to change.

61 61 GOLDEN RULE OF OBJECT CREATION Try to make an object responsible for using or creating, but never both.

62 62 LAST WEEK Next week Monday guest lecture by Jan Martijn vd Werf Next week Thursday no lecture, but there is lab assistance Come to the guest lecture! Learn!

63 63 MATERIAL COVERED Design Patterns explained. Chapter 19-24

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

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

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

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

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

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

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

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

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

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

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 Creational Design Patterns What are creational design patterns? Types Examples Structure Effects Creational Patterns Design patterns that deal with object

More information

Lecture 13: Design Patterns

Lecture 13: Design Patterns 1 Lecture 13: Design Patterns Kenneth M. Anderson Object-Oriented Analysis and Design CSCI 6448 - Spring Semester, 2005 2 Pattern Resources Pattern Languages of Programming Technical conference on Patterns

More information

Pattern Resources. Lecture 25: Design Patterns. What are Patterns? Design Patterns. Pattern Languages of Programming. The Portland Pattern Repository

Pattern Resources. Lecture 25: Design Patterns. What are Patterns? Design Patterns. Pattern Languages of Programming. The Portland Pattern Repository Pattern Resources Lecture 25: Design Patterns Kenneth M. Anderson Object-Oriented Analysis and Design CSCI 6448 - Spring Semester, 2003 Pattern Languages of Programming Technical conference on Patterns

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

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

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

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 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

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

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

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

MSO Exam November 7, 2016, 13:30 15:30, Educ-Gamma

MSO Exam November 7, 2016, 13:30 15:30, Educ-Gamma MSO 2016 2017 Exam November 7, 2016, 13:30 15:30, Educ-Gamma Name: Student number: Please read the following instructions carefully: Fill in your name and student number above. Be prepared to identify

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

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

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

OODP Session 5a.   Web Page:  Visiting Hours: Tuesday 17:00 to 19:00 OODP Session 5a Next week: Reading week 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

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

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

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

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

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

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

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

Introduction to Design Patterns

Introduction to Design Patterns Dr. Michael Eichberg Software Engineering Department of Computer Science Technische Universität Darmstadt Software Engineering Introduction to Design Patterns (Design) Patterns A pattern describes... Patterns

More information

Review Software Engineering October, 7, Adrian Iftene

Review Software Engineering October, 7, Adrian Iftene Review Software Engineering October, 7, 2013 Adrian Iftene adiftene@info.uaic.ro Software engineering Basics Definition Development models Development activities Requirement analysis Modeling (UML Diagrams)

More information

Introduction to Design Patterns

Introduction to Design Patterns Dr. Michael Eichberg Software Technology Group Department of Computer Science Technische Universität Darmstadt Introduction to Software Engineering Introduction to Design Patterns Patterns 2 PATTERNS A

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

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

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

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

Essential Skills for the Agile Developer. Agile. copyright Net Objectives, Inc.

Essential Skills for the Agile Developer. Agile. copyright Net Objectives, Inc. Essential Skills for the Agile Developer Agile copyright 2010. Net Objectives, Inc. Lean for Executives Product Portfolio Management Business Lean Enterprise ASSESSMENTS CONSULTING TRAINING COACHING Team

More information

Tutorial: Functions and Functional Abstraction. Nathaniel Osgood CMPT

Tutorial: Functions and Functional Abstraction. Nathaniel Osgood CMPT Tutorial: Functions and Functional Abstraction Nathaniel Osgood CMPT 858 2-8-2011 Building the Model Right: Some Principles of Software Engineering Technical guidelines Try to avoid needless complexity

More information

CHAPTER 6: CREATIONAL DESIGN PATTERNS

CHAPTER 6: CREATIONAL DESIGN PATTERNS CHAPTER 6: CREATIONAL DESIGN PATTERNS SESSION III: BUILDER, PROTOTYPE, SINGLETON Software Engineering Design: Theory and Practice by Carlos E. Otero Slides copyright 2012 by Carlos E. Otero For non-profit

More information

What is Design Patterns?

What is Design Patterns? Paweł Zajączkowski What is Design Patterns? 1. Design patterns may be said as a set of probable solutions for a particular problem which is tested to work best in certain situations. 2. In other words,

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

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

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

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

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

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

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

MSO Lecture 11. Wouter Swierstra (adapted by HP) October 23, 2017 1 MSO Lecture 11 Wouter Swierstra (adapted by HP) October 23, 2017 2 REVIEW Object oriented analysis: UP requirements use cases domain models GRASP principles Design patterns: Facade Adapter Bridge Strategy

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

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

CPSC 310: Sample Final Exam Study Questions 2014S1 (These are in addition to the Study Questions listed at the end of some lectures)

CPSC 310: Sample Final Exam Study Questions 2014S1 (These are in addition to the Study Questions listed at the end of some lectures) CPSC 310: Sample Final Exam Study Questions 2014S1 (These are in addition to the Study Questions listed at the end of some lectures) 1. Select the best functional requirement from the list of requirements

More information

Thread Safety. Review. Today o Confinement o Threadsafe datatypes Required reading. Concurrency Wrapper Collections

Thread Safety. Review. Today o Confinement o Threadsafe datatypes Required reading. Concurrency Wrapper Collections Thread Safety Today o Confinement o Threadsafe datatypes Required reading Concurrency Wrapper Collections Optional reading The material in this lecture and the next lecture is inspired by an excellent

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

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

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

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

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

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

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

Applying Some Gang of Four Design Patterns CSSE 574: Session 5, Part 3

Applying Some Gang of Four Design Patterns CSSE 574: Session 5, Part 3 Applying Some Gang of Four Design Patterns CSSE 574: Session 5, Part 3 Steve Chenoweth Phone: Office (812) 877-8974 Cell (937) 657-3885 Email: chenowet@rose-hulman.edu Gang of Four (GoF) http://www.research.ibm.com/designpatterns/pubs/ddj-eip-award.htm

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

Singleton Pattern Creational

Singleton Pattern Creational Singleton Pattern Creational Intent» Ensure a class has only one instance» Provide a global point of access Motivation Some classes must only have one instance file system, window manager Applicability»

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

CS 351 Design of Large Programs Singleton Pattern

CS 351 Design of Large Programs Singleton Pattern CS 351 Design of Large Programs Singleton Pattern Brooke Chenoweth University of New Mexico Spring 2019 The Notion of a Singleton There are many objects we only need one of: Thread pools, caches, dialog

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

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

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

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

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

VOL. 4, NO. 12, December 2014 ISSN ARPN Journal of Science and Technology All rights reserved.

VOL. 4, NO. 12, December 2014 ISSN ARPN Journal of Science and Technology All rights reserved. Simplifying the Abstract Factory and Factory Design Patterns 1 Egbenimi Beredugo Eskca, 2 Sandeep Bondugula, 3 El Taeib Tarik 1, 2, 3 Department of Computer Science, University of Bridgeport, Bridgeport

More information

Lectures 24 and 25 Introduction to Architectural Styles and Design Patterns

Lectures 24 and 25 Introduction to Architectural Styles and Design Patterns Lectures 24 and 25 Introduction to Architectural Styles and Design Patterns Software Engineering ITCS 3155 Fall 2008 Dr. Jamie Payton Department of Computer Science University of North Carolina at Charlotte

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

Software Design and Analysis for Engineers

Software Design and Analysis for Engineers Software Design and Analysis for Engineers by Dr. Lesley Shannon Email: lshannon@ensc.sfu.ca Course Website: http://www.ensc.sfu.ca/~lshannon/courses/ensc251 Simon Fraser University Slide Set: 2 Date:

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

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

Object Oriented Paradigm

Object Oriented Paradigm Object Oriented Paradigm Ming-Hwa Wang, Ph.D. Department of Computer Engineering Santa Clara University Object Oriented Paradigm/Programming (OOP) similar to Lego, which kids build new toys from assembling

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

05. SINGLETON PATTERN. One of a Kind Objects

05. SINGLETON PATTERN. One of a Kind Objects BIM492 DESIGN PATTERNS 05. SINGLETON PATTERN One of a Kind Objects Developer: What use is that? Guru: There are many objects we only need one of: thread pools, caches, dialog boxes, objects that handle

More information

DESIGN PATTERNS FOR MERE MORTALS

DESIGN PATTERNS FOR MERE MORTALS DESIGN PATTERNS FOR MERE MORTALS Philip Japikse (@skimedic) skimedic@outlook.com www.skimedic.com/blog Microsoft MVP, ASPInsider, MCSD, MCDBA, CSM, CSP Consultant, Teacher, Writer Phil.About() Consultant,

More information

Lecturer: Sebastian Coope Ashton Building, Room G.18 COMP 201 web-page:

Lecturer: Sebastian Coope Ashton Building, Room G.18   COMP 201 web-page: Lecturer: Sebastian Coope Ashton Building, Room G.18 E-mail: coopes@liverpool.ac.uk COMP 201 web-page: http://www.csc.liv.ac.uk/~coopes/comp201 Lecture 17 Concepts of Object Oriented Design Object-Oriented

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

Design Patterns. SE3A04 Tutorial. Jason Jaskolka

Design Patterns. SE3A04 Tutorial. Jason Jaskolka SE3A04 Tutorial Jason Jaskolka Department of Computing and Software Faculty of Engineering McMaster University Hamilton, Ontario, Canada jaskolj@mcmaster.ca November 18/19, 2014 Jason Jaskolka 1 / 35 1

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

SOLID DESIGN PATTERNS FOR MERE MORTALS

SOLID DESIGN PATTERNS FOR MERE MORTALS SOLID DESIGN PATTERNS FOR MERE MORTALS Philip Japikse (@skimedic) skimedic@outlook.com www.skimedic.com/blog Microsoft MVP, ASPInsider, MCSD, MCDBA, CSM, PSM, PSD Consultant, Teacher, Writer Phil.About()

More information

Introduction to Software Engineering (2+1 SWS) Winter Term 2009 / 2010 Dr. Michael Eichberg Vertretungsprofessur Software Engineering Department of

Introduction to Software Engineering (2+1 SWS) Winter Term 2009 / 2010 Dr. Michael Eichberg Vertretungsprofessur Software Engineering Department of Introduction to Software Engineering (2+1 SWS) Winter Term 2009 / 2010 Dr. Michael Eichberg Vertretungsprofessur Software Engineering Department of Computer Science Technische Universität Darmstadt Dr.

More information

Concurrency: State Models & Design Patterns

Concurrency: State Models & Design Patterns Concurrency: State Models & Design Patterns Practical Session Week 02 1 / 13 Exercises 01 Discussion Exercise 01 - Task 1 a) Do recent central processing units (CPUs) of desktop PCs support concurrency?

More information

Design Patterns Thinking and Architecture at Scale

Design Patterns Thinking and Architecture at Scale Design Patterns Thinking and Architecture at Scale This talk is based on Net Objectives design patterns training and Al Shalloway and Jim Trott s book Design Patterns Explained. Please contact Al at alshall@netobjectives.com

More information

A - 1. CS 494 Object-Oriented Analysis & Design. UML Class Models. Overview. Class Model Perspectives (cont d) Developing Class Models

A - 1. CS 494 Object-Oriented Analysis & Design. UML Class Models. Overview. Class Model Perspectives (cont d) Developing Class Models CS 494 Object-Oriented Analysis & Design UML Class Models Overview How class models are used? Perspectives Classes: attributes and operations Associations Multiplicity Generalization and Inheritance Aggregation

More information

Template Method. Kenneth M. Anderson University of Colorado, Boulder CSCI 4448/6448 Lecture 24 11/15/2007. University of Colorado, 2007

Template Method. Kenneth M. Anderson University of Colorado, Boulder CSCI 4448/6448 Lecture 24 11/15/2007. University of Colorado, 2007 Template Method Kenneth M. Anderson University of Colorado, Boulder CSCI 4448/6448 Lecture 24 11/15/2007 University of Colorado, 2007 1 Lecture Goals Cover Material from Chapter 8 of the Design Patterns

More information

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

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

A4 Explain how the Visitor design pattern works (4 marks)

A4 Explain how the Visitor design pattern works (4 marks) COMP61532 exam Performance feedback Original marking scheme in bold, additional comments in bold italic. Section A In general the level of English was poor, spelling and grammar was a problem in most cases.

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

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

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

Implementing GUI context-sensitive help... ECE450 Software Engineering II. Implementing GUI context-sensitive help... Context-sensitive help

Implementing GUI context-sensitive help... ECE450 Software Engineering II. Implementing GUI context-sensitive help... Context-sensitive help Implementing GUI context-sensitive help... ECE450 Software Engineering II Today: Design Patterns VIII Chain of Responsibility, Strategy, State ECE450 - Software Engineering II 1 ECE450 - Software Engineering

More information

4.1 Introduction Programming preliminaries Constructors Destructors An example... 3

4.1 Introduction Programming preliminaries Constructors Destructors An example... 3 Department of Computer Science Tackling Design Patterns Chapter 4: Factory Method design pattern Copyright c 2016 by Linda Marshall and Vreda Pieterse. All rights reserved. Contents 4.1 Introduction.................................

More information