Design Patterns (Composite)

Size: px
Start display at page:

Download "Design Patterns (Composite)"

Transcription

1 CS 247: Software Engineering Principles Design Patterns (Composite) Reading: Freeman, Robson, Bates, Sierra, Head First Design Patterns, O'Reilly Media, Inc Ch 9: Composite and Iterator Patterns Electronic text available from UW Library Web site U Waterloo CS247 (Spring 2017) p.1/20

2 Today's Agenda Design patterns: codified solutions that put design principles into practice, to improve the modularity of our code. OO Basics Favour Composition over Inheritance Facade Separation of Concerns Single Responsibility Principle Observer Encapsulate what is likely to change Dependency Inversion PrincipleModel-View-Controller (MVC) Encapsulate Data Representation Liskov Substitutability PrincipleComposite Abstraction (interfaces, ADTs) Law of Demeter Iterator Reuse (through composition, inheritance) Polymorphism Open Closed Principle OO Principles Strategy Design Patterns Template Method Adaptor U Waterloo CS247 (Spring 2017) p.2/20

3 Review: Object Composition A compound object represents a composition of heterogeneous, possibly recursive, component objects. Law of Demeter: client code interacts with compound object. Book Section Developer 0..1 Team subteam 1 Page U Waterloo CS247 (Spring 2017) p.3/20

4 Composite Design Pattern (Idea) The Composite Pattern takes a different approach: gives the client access to all member types in a compound object via a uniform interface. Client Code TeamMember Developer Team Client Code BookUnit Page Chapter U Waterloo CS247 (Spring 2017) p.4/20

5 Metaphor: Composite Pattern collection of devices, each with its own interface Universal Interface for (recursive) collection of devices U Waterloo CS247 (Spring 2017) p.5/20

6 Composite Pattern Problem: composite object consists of several heterogenous parts Client code is complicated by knowledge of object structure. Client must change if data structure changes. Solution: create a uniform interface for the object's components. Interface advertises all operations that components offer. Client deals only with the new uniform interface. Uniform interface is the union of the components' services. Client Code Component Operation add(component) Remove(Component) GetChild(int) part Leaf Operation Composite Operation add(component) Remove(Component) GetChild(int) U Waterloo CS247 (Spring 2017) p.6/20

7 Example 0..1 Developer Project Team subteam TeamMember name : string salary() : int print() add(teammember) getmember(int) member Developer salary: int salary() print() ProjectTeam print() add(teammember) getmember(int) U Waterloo CS247 (Spring 2017) p.7/20

8 Team Example Heroes Fantastic Four Avengers SHIELD Human Torch The Thing... Hulk Thor Nick Fury Skrulls Iron Man Ethan Edwards Jazinda Avengers Hulk Hulk Thor Iron Man U Waterloo CS247 (Spring 2017) p.8/20

9 class TeamMember { public: virtual ~TeamMember() {} Uniform Interface // leaf-only operations virtual int salary() const { return 0;} // component-only operations virtual void add(teammember) { } virtual TeamMember getmember(int) const {return nullptr;} // shared operations virtual void print() const { std::cout << name_; } protected: TeamMember( const std::string& name ); private: std::string name_; }; U Waterloo CS247 (Spring 2017) p.9/20

10 The leaf classes override the behaviour of leaf-object operations. class Developer : public TeamMember { public: Developer( const std::string&, int); // redefine leaf-only operations virtual int salary() const { return salary_; } // inherit component-only operations // redefine shared operations virtual void print() const; private: int salary_; }; Leaf Class U Waterloo CS247 (Spring 2017) p.10/20

11 Concrete Composite Class class Team : public TeamMember { public: Team ( const std::string& ); virtual ~Team(); // inherit leaf-only operations // redefine component-only operations virtual void add(teammember); virtual TeamMember getmember(int) const; // redefine shared operations virtual void print() const; private: vector<teammember> members_; }; TeamMember Team::getMember(int i) const { return members_.at(i); } U Waterloo CS247 (Spring 2017) p.11/20

12 Uniformity vs. Safety Whether to include component-specific operations in the component interface involves a trade-off between: uniformity - preserving the illusion that component objects can be treated the same way. - Promoted by the Composite Design Pattern. safety - avoiding cases where the client attempts to do something meaningless, like adding components to Leaf objects. - Promoted by Liskov Substitutability Principle. U Waterloo CS247 (Spring 2017) p.12/20

13 Another Example: Expressions 2 Expression value() name() print() left() : Expr right() : Expr Expressions: a+b ab+c-d a BinaryExpr left() : Expr right() : Expr print() Variable name value name() value() print() Plus Minus Multiply Divide U Waterloo CS247 (Spring 2017) p.13/20

14 Composite Pattern TeamMember name : string salary() : int print() add(teammember) getmember(int) member Developer salary: int salary() print() ProjectTeam print() add(teammember) getmember(int) Consequences: + Client deals only with the new uniform interface. + New leafs and composite types are easy to add. New operations are harder to add (Visitor Pattern). How can client code iterate through a composite object without knowing the composite's structure? U Waterloo CS247 (Spring 2017) p.14/20

15 Recap: Composite Pattern Problem: composite object consists of several heterogenous parts. Client code is complicated by knowledge of object structure. Client must change if data structure changes. Solution: create a uniform interface for the object's components. Interface advertises all operations that components offer. Client deals only with the new uniform interface. Uniform interface is the union of the components' services. Client Code Component Operation add(component) Remove(Component) GetChild(int) part Operation Leaf Composite Operation add(component) Remove(Component) GetChild(int) U Waterloo CS247 (Spring 2017) p.15/20

16 When Should I Use the Composite Pattern? What's the story? First you tell us Single Responsibility and Substitutability, and now you are giving us a pattern where one class manages the operations of two completely different subclasses. skeptic U Waterloo CS247 (Spring 2017) p.16/20

17 When Should I Use the Composite Pattern? What's the story? First you tell us Single Responsibility and Substitutability, and now you are giving us a pattern where one class manages the operations of two completely different subclasses. When client mostly treats the structure uniformly client usually ignores differences in element types mostly transverses entire composition there exist reasonable default implementations of operations skeptic U Waterloo CS247 (Spring 2017) p.17/20

18 When Should I Use the Composite Pattern? What's the story? First you tell us Single Responsibility and Substitutability, and now you are giving us a pattern where one class manages the operations of two completely different subclasses. When client mostly treats the structure uniformly client usually ignores differences in element types mostly transverses entire composition there exist reasonable default implementations of operations Alternative is to keep element types distinct all calls to inappropriate operations are caught skeptic U Waterloo CS247 (Spring 2017) p.18/20

19 When Should I Use the Composite Pattern? What's the story? First you tell us Single Responsibility and Substitutability, and now you are giving us a pattern where one class manages the operations of two completely different subclasses. When client mostly treats the structure uniformly client usually ignores differences in element types mostly transverses entire composition there exist reasonable default implementations of operations TRANSPARENCY Alternative is to keep element types distinct all calls to inappropriate operations are caught SAFETY skeptic U Waterloo CS247 (Spring 2017) p.19/20

20 Summary The goal of design patterns is to encapsulate change. Facade Pattern: encapsulates a collection of (complex?) classes. Composite Pattern: encapsulates the structure of a heterogeneous, possibly recursive data structure. U Waterloo CS247 (Spring 2017) p.20/20

Design Patterns (Facade, Composite)

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

More information

Design Patterns (Composite, Iterator)

Design Patterns (Composite, Iterator) CS 246: Software Abstraction and Specification Lecture 17 Design Patterns (Composite, Iterator) Reading: Head First Design Patterns U Waterloo CS246se (Spring 2011) p.1/30 Today's Agenda Design patterns:

More information

Design Patterns (Iterator)

Design Patterns (Iterator) CS 247: Software Engineering Principles Design Patterns (Iterator) Reading: Freeman, Robson, Bates, Sierra, Head First Design Patterns, O'Reilly Media, Inc. 2004 Ch 9: Composite and Iterator Patterns Electronic

More information

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

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

More information

CS 247: Software Engineering Principles. Design Patterns

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

More information

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

Today's Agenda. References. Open Closed Principle. CS 247: Software Engineering Principles. Object-Oriented Design Principles

Today's Agenda. References. Open Closed Principle. CS 247: Software Engineering Principles. Object-Oriented Design Principles CS 247: Software Engineering Principles Reading: none Object-Oriented Design Principles Today's Agenda Object-Oriented Design Principles - characteristics, properties, and advice for making decisions that

More information

Object-Oriented Oriented Programming

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

More information

Design Pattern: Composite

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

More information

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

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

More information

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

The Composite Design Pattern

The Composite Design Pattern Dr. Michael Eichberg Software Technology Group Department of Computer Science Technische Universität Darmstadt Introduction to Software Engineering The Composite Design Pattern For details see Gamma et

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

Tecniche di Progettazione: Design Patterns

Tecniche di Progettazione: Design Patterns Tecniche di Progettazione: Design Patterns GoF: Composite 1 Composite pattern Intent Compose objects into tree structures to represent part-whole hierarchies. Composite lets clients treat individual objects

More information

Software Eningeering. Lecture 9 Design Patterns 2

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

More information

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

CS250 Intro to CS II. Spring CS250 - Intro to CS II 1

CS250 Intro to CS II. Spring CS250 - Intro to CS II 1 CS250 Intro to CS II Spring 2017 CS250 - Intro to CS II 1 Topics Virtual Functions Pure Virtual Functions Abstract Classes Concrete Classes Binding Time, Static Binding, Dynamic Binding Overriding vs Redefining

More information

Design Patterns Lecture 2

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

More information

Design Patterns. 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 Composite Pattern

The Composite Pattern The Composite Pattern Intent Compose objects into tree structures to represent part-whole hierarchies. Composite lets clients treat individual objects and compositions of objects uniformly. This is called

More information

CS 520 Theory and Practice of Software Engineering Fall 2018

CS 520 Theory and Practice of Software Engineering Fall 2018 Today CS 520 Theory and Practice of Software Engineering Fall 2018 Object Oriented (OO) Design Principles September 13, 2018 Code review and (re)design of an MVC application (and encapsulation) Polymorphism

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

Data Structures and Algorithms Design Goals Implementation Goals Design Principles Design Techniques. Version 03.s 2-1

Data Structures and Algorithms Design Goals Implementation Goals Design Principles Design Techniques. Version 03.s 2-1 Design Principles Data Structures and Algorithms Design Goals Implementation Goals Design Principles Design Techniques 2-1 Data Structures Data Structure - A systematic way of organizing and accessing

More information

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

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

More information

Design Patterns. Decorator. Oliver Haase

Design Patterns. Decorator. Oliver Haase Design Patterns Decorator Oliver Haase 1 Motivation Your task is to program a coffee machine. The machine brews plain coffee, coffee with cream, sugar, sweetener, and cinnamon. A plain coffee costs 0,90,

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

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

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

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

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

20. Inheritance and Polymorphism

20. Inheritance and Polymorphism (Expression) Trees 20. Inheritance and Polymorphism Expression Trees, Inheritance, Code-Reuse, Virtual Functions, Polymorphism, Concepts of Object Oriented Programming bend fork 3 -(3-(4-5))*(3+4*5)/6

More information

Object Design II: Design Patterns

Object Design II: Design Patterns Object-Oriented Software Engineering Using UML, Patterns, and Java Object Design II: Design Patterns Bernd Bruegge Applied Software Engineering Technische Universitaet Muenchen A Game: Get-15 The game

More information

CS 520 Theory and Practice of Software Engineering Fall 2017

CS 520 Theory and Practice of Software Engineering Fall 2017 CS 520 Theory and Practice of Software Engineering Fall 2017 OO design principles September 14, 2017 Today Code review and (re)design of an MVC application OO design principles Information hiding (and

More information

Software Engineering

Software Engineering Software Engineering CSC 331/631 - Spring 2018 Object-Oriented Design Principles Paul Pauca April 10 Design Principles DP1. Identify aspects of the application that vary and separate them from what stays

More information

CISC 322 Software Architecture

CISC 322 Software Architecture CISC 322 Software Architecture Lecture 14: Design Patterns Emad Shihab Material drawn from [Gamma95, Coplien95] Slides adapted from Spiros Mancoridis and Ahmed E. Hassan Motivation Good designers know

More information

2.1 Design Patterns and Architecture (continued)

2.1 Design Patterns and Architecture (continued) MBSE - 2.1 Design Patterns and Architecture 1 2.1 Design Patterns and Architecture (continued) 1. Introduction 2. Model Construction 2.1 Design Patterns and Architecture 2.2 State Machines 2.3 Timed Automata

More information

CS 320 Introduction to Software Engineering Spring March 06, 2017

CS 320 Introduction to Software Engineering Spring March 06, 2017 CS 320 Introduction to Software Engineering Spring 2017 March 06, 2017 Recap: types of Polymorphism Recap: types of Polymorphism Ad-hoc polymorphism (e.g., operator overloading) a + b String vs. int, double,

More information

2.1 Design Patterns and Architecture (continued)

2.1 Design Patterns and Architecture (continued) MBSE - 2.1 Design Patterns and Architecture 1 2.1 Design Patterns and Architecture (continued) 1. Introduction 2. Model Construction 2.1 Design Patterns and Architecture 2.2 State Machines 2.3 Abstract

More information

Produced by. Design Patterns. MSc in Computer Science. Eamonn de Leastar

Produced by. Design Patterns. MSc in Computer Science. Eamonn de Leastar Design Patterns MSc in Computer Science 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

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

Improve Your SystemVerilog OOP Skills

Improve Your SystemVerilog OOP Skills 1 Improve Your SystemVerilog OOP Skills By Learning Principles and Patterns Jason Sprott Verilab Email: jason.sprott@verilab.com www.verilab.com Experts in SV Learn Design Patterns 2 Look, you don t need

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

Object Fundamentals, Part One. Kenneth M. Anderson University of Colorado, Boulder CSCI 4448/5448 Lecture 2 08/27/2009

Object Fundamentals, Part One. Kenneth M. Anderson University of Colorado, Boulder CSCI 4448/5448 Lecture 2 08/27/2009 Object Fundamentals, Part One Kenneth M. Anderson University of Colorado, Boulder CSCI 4448/5448 Lecture 2 08/27/2009 1 Lecture Goals Introduce basic concepts, terminology, and notations for object-oriented

More information

COURSE 2 DESIGN PATTERNS

COURSE 2 DESIGN PATTERNS COURSE 2 DESIGN PATTERNS CONTENT Fundamental principles of OOP Encapsulation Inheritance Abstractisation Polymorphism [Exception Handling] Fundamental Patterns Inheritance Delegation Interface Abstract

More information

Design patterns. Valentina Presutti courtesy of Paolo Ciancarini

Design patterns. Valentina Presutti courtesy of Paolo Ciancarini Design patterns Valentina Presutti courtesy of Paolo Ciancarini Agenda What are design patterns? Catalogues of patterns Languages of patterns Two case studies: design with patterns Software Architectures

More information

Spring 2003 Instructor: Dr. Shahadat Hossain. Administrative Matters Course Information Introduction to Programming Techniques

Spring 2003 Instructor: Dr. Shahadat Hossain. Administrative Matters Course Information Introduction to Programming Techniques 1 CPSC2620 Advanced Programming Spring 2003 Instructor: Dr. Shahadat Hossain 2 Today s Agenda Administrative Matters Course Information Introduction to Programming Techniques 3 Course Assessment Lectures:

More information

Design Patterns. Paul Jackson. School of Informatics University of Edinburgh

Design Patterns. Paul Jackson. School of Informatics University of Edinburgh Design Patterns Paul Jackson School of Informatics University of Edinburgh Design Patterns Reuse of good ideas A pattern is a named, well understood good solution to a common problem. Experienced designers

More information

Special Member Functions

Special Member Functions CS 247: Software Engineering Principles Special Member Functions Readings: Eckel, Vol. 1 Ch. 11 References and the Copy Constructor Ch. 12 Operator Overloading ( operator= ) U Waterloo CS247 (Spring 2017)

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

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

Special Member Functions. Compiler-Generated Destructor. Compiler-Generated Default Constructor. Special Member Functions

Special Member Functions. Compiler-Generated Destructor. Compiler-Generated Default Constructor. Special Member Functions Special Member Functions CS 247: Software Engineering Principles Special Member Functions Readings: Eckel, Vol. 1 Ch. 11 References and the Copy Constructor Ch. 12 Operator Overloading ( operator= ) C++

More information

Inheritance. OOP components. Another Example. Is a Vs Has a. Virtual Destructor rule. Virtual Functions 4/13/2017

Inheritance. OOP components. Another Example. Is a Vs Has a. Virtual Destructor rule. Virtual Functions 4/13/2017 OOP components For : COP 3330. Object oriented Programming (Using C++) http://www.compgeom.com/~piyush/teach/3330 Data Abstraction Information Hiding, ADTs Encapsulation Type Extensibility Operator Overloading

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

CS304 Object Oriented Programming Final Term

CS304 Object Oriented Programming Final Term 1. Which of the following is the way to extract common behaviour and attributes from the given classes and make a separate class of those common behaviours and attributes? Generalization (pg 29) Sub-typing

More information

What are the characteristics of Object Oriented programming language?

What are the characteristics of Object Oriented programming language? What are the various elements of OOP? Following are the various elements of OOP:- Class:- A class is a collection of data and the various operations that can be performed on that data. Object- This is

More information

Design Patterns. Definition of a Design Pattern

Design Patterns. Definition of a Design Pattern Design Patterns Barbara Russo Definition of a Design Pattern A Pattern describes a problem which occurs over and over again in our environment, and then describes the core of the solution to that problem,

More information

Object-Oriented Languages and Object-Oriented Design. Ghezzi&Jazayeri: OO Languages 1

Object-Oriented Languages and Object-Oriented Design. Ghezzi&Jazayeri: OO Languages 1 Object-Oriented Languages and Object-Oriented Design Ghezzi&Jazayeri: OO Languages 1 What is an OO language? In Ada and Modula 2 one can define objects encapsulate a data structure and relevant operations

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

Exam in TDDB84: Design Patterns,

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

More information

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

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

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

More information

Abstraction. Design fundamentals in OO Systems. Fundamental Software Development Principles

Abstraction. Design fundamentals in OO Systems. Fundamental Software Development Principles Abstraction Design fundamentals in OO Systems Tool for abstraction: object Object structure: properties and values for those properties operations to query and update those properties We refer to the collection

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

Introduction to Object-Oriented Programming

Introduction to Object-Oriented Programming Polymorphism 1 / 19 Introduction to Object-Oriented Programming Today we ll learn how to combine all the elements of object-oriented programming in the design of a program that handles a company payroll.

More information

Object Fundamentals. Kenneth M. Anderson University of Colorado, Boulder CSCI 4448/6448 Lecture 2 08/30/2007

Object Fundamentals. Kenneth M. Anderson University of Colorado, Boulder CSCI 4448/6448 Lecture 2 08/30/2007 Object Fundamentals Kenneth M. Anderson University of Colorado, Boulder CSCI 4448/6448 Lecture 2 08/30/2007 1 Lecture Goals Introduce basic concepts, terminology, and notations for object-oriented analysis,

More information

Introduction to Software Engineering: Object Design I Reuse & Patterns

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

More information

Applying Design Patterns to accelerate development of reusable, configurable and portable UVCs. Accellera Systems Initiative 1

Applying Design Patterns to accelerate development of reusable, configurable and portable UVCs. Accellera Systems Initiative 1 Applying Design Patterns to accelerate development of reusable, configurable and portable UVCs. Accellera Systems Initiative 1 About the presenter Paul Kaunds Paul Kaunds is a Verification Consultant at

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

CS246 Software Abstraction and Specification Final Examination

CS246 Software Abstraction and Specification Final Examination CS246 Software Abstraction and Specification ination Spring 2007 Date: 04-Aug-2007 Time: 4.00 6.30pm Permitted Aids: None 14 pages Student Name: UW Student ID: Instructions: (Read carefully before the

More information

Composite Pattern. IV.4 Structural Pattern

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

More information

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

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

CS 520 Theory and Practice of Software Engineering Fall 2018

CS 520 Theory and Practice of Software Engineering Fall 2018 Today CS 520 Theory and Practice of Software Engineering Fall 208 Object Oriented Design Patterns Recap: Object oriented design principles Design problems & potential solutions Design patterns: What is

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

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

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

Patterns for polymorphic operations

Patterns for polymorphic operations Patterns for polymorphic operations Three small object structural patterns for dealing with polymorphism Alexander A. Horoshilov hor@epsylontech.com Abstract Polymorphism is one of the main elements of

More information

Outline. Subtype Polymorphism, Subtyping vs. Subclassing, Liskov Substitution Principle. Benefits of Subtype Polymorphism. Subtype Polymorphism

Outline. Subtype Polymorphism, Subtyping vs. Subclassing, Liskov Substitution Principle. Benefits of Subtype Polymorphism. Subtype Polymorphism Subtype, Subtyping vs. Subclassing, Liskov Substitution Principle Outline Subtype polymorphism Subtyping vs. subclassing Liskov Substitution Principle (LSP) Function subtyping Java subtyping Composition:

More information

Object-Oriented Concepts and Design Principles

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

More information

ECE 3574: Dynamic Polymorphism using Inheritance

ECE 3574: Dynamic Polymorphism using Inheritance 1 ECE 3574: Dynamic Polymorphism using Inheritance Changwoo Min 2 Administrivia Survey on class will be out tonight or tomorrow night Please, let me share your idea to improve the class! 3 Meeting 10:

More information

C++ Modern and Lucid C++ for Professional Programmers

C++ Modern and Lucid C++ for Professional Programmers Informatik C++ Modern and Lucid C++ for Professional Programmers part 13 Prof. Peter Sommerlad Institutsleiter IFS Institute for Software Rapperswil, HS 2015 Inheritance and dynamic Polymorphism base classes,

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

Admin. CS 112 Introduction to Programming. Recap: OOP Analysis. Software Design and Reuse. Recap: OOP Analysis. Inheritance

Admin. CS 112 Introduction to Programming. Recap: OOP Analysis. Software Design and Reuse. Recap: OOP Analysis. Inheritance Admin CS 112 Introduction to Programming q Class project Inheritance Yang (Richard) Yang Computer Science Department Yale University 308A Watson, Phone: 432-6400 Email: yry@cs.yale.edu 2 Recap: OOP Analysis

More information

FINAL TERM EXAMINATION SPRING 2010 CS304- OBJECT ORIENTED PROGRAMMING

FINAL TERM EXAMINATION SPRING 2010 CS304- OBJECT ORIENTED PROGRAMMING FINAL TERM EXAMINATION SPRING 2010 CS304- OBJECT ORIENTED PROGRAMMING Question No: 1 ( Marks: 1 ) - Please choose one Classes like TwoDimensionalShape and ThreeDimensionalShape would normally be concrete,

More information

Value vs. Entity Objects, Information Hiding

Value vs. Entity Objects, Information Hiding CS 247: Software Engineering Principles Value vs. Entity Objects, Information Hiding Readings: Eckel, Vol. 1 Ch. 5 Hiding the Implementation U Waterloo CS247 (Spring 2017) p.1/12 Entity vs. Value Objects

More information

Adapter Pattern Structural

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

More information

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

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

Entity vs. Value, Modules, Hidden Implementation, Interface Specification

Entity vs. Value, Modules, Hidden Implementation, Interface Specification Entity vs. Value, Modules, Hidden Implementation, Interface Specification CS 247 University of Waterloo cs247@uwaterloo.ca May 19, 2017 CS 247 (UW) Tutorial 3 May 19, 2017 1 / 24 Overview 1 Move Constructors,

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

Design Patterns V Structural Design Patterns, 2

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

More information

Object Oriented Programming in Java. Jaanus Pöial, PhD Tallinn, Estonia

Object Oriented Programming in Java. Jaanus Pöial, PhD Tallinn, Estonia Object Oriented Programming in Java Jaanus Pöial, PhD Tallinn, Estonia Motivation for Object Oriented Programming Decrease complexity (use layers of abstraction, interfaces, modularity,...) Reuse existing

More information

Object Oriented Programming

Object Oriented Programming OOP Object Oriented Programming Object 2 Object 1 Object 3 For : COP 3330. Object oriented Programming (Using C++) Object 4 http://www.compgeom.com/~piyush/teach/3330 Piyush Kumar Objects: State (fields),

More information

Design Patterns. Lecture 10: OOP, autumn 2003

Design Patterns. Lecture 10: OOP, autumn 2003 Design Patterns Lecture 10: OOP, autumn 2003 What are patterns? Many recurring problems are solved in similar ways This wisdom is collected into patterns design patterns - about software design Other kinds

More information

18. Inheritance and Polymorphism

18. Inheritance and Polymorphism (Expression) Trees -(3-(4-5))*(3+4*5)/6 18. Inheritance and Polymorphism fork fork / root 6 Expression Trees, Inheritance, Code-Reuse, Virtual Functions, Polymorphism, Concepts of Object Oriented Programming

More information

What are patterns? Design Patterns. Design patterns. Creational patterns. The factory pattern. Factory pattern structure. Lecture 10: OOP, autumn 2003

What are patterns? Design Patterns. Design patterns. Creational patterns. The factory pattern. Factory pattern structure. Lecture 10: OOP, autumn 2003 What are patterns? Design Patterns Lecture 10: OOP, autumn 2003 Many recurring problems are solved in similar ways This wisdom is collected into patterns design patterns - about software design Other kinds

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

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

CS 520/620 Advanced Software Engineering Spring February 02, 2016 CS 520/620 Advanced Software Engineering Spring 2016 February 02, 2016 Logistics Project proposals Elevator pitches on Thursday Deadline for creating groups: 02/03/2016, 11:55pm Deadline for submitting

More information

Top Down Design vs. Modularization

Top Down Design vs. Modularization 6.170 Quiz Review Topics: 1. Decoupling 2. 3. AF & RI 4. Iteration Abstraction & Iterators 5. OMs and Invariants 6. Equality, Copying, Views 7. 8. Design Patterns 9. Subtyping 10. Case Studies Decomposition

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