Introduction to Object Oriented / Functional Programming 9. Object-Oriented Software Development COMP4001 CSE UNSW Sydney Lecturer: John Potter
|
|
- Ann Tate
- 5 years ago
- Views:
Transcription
1 Introduction to Object Oriented / Functional Programming 9 Object-Oriented Software Development COMP4001 CSE UNSW Sydney Lecturer: John Potter
2 Lecture Outline object equality design patterns composite interpreter visitor extensibility COMP4001 CSE UNSW Sydney 2
3 Object Equality most OO languages allow user-defined object equality and hashcodes Java, hence Scala, have specific rules that programmers must follow 1. if two objects are equal then they must have the same hashcode the converse is not possible in general, but the probability of two unequal objects having the same hashcodes should be small 2. equality == must be an equivalence relation reflexive: identical objects must be equal symmetric: if x == y then y == x transitive: if x == y and y == z then x == z COMP4001 CSE UNSW Sydney 3
4 Java: object equality & hashcode x == y tests object identity not overridable also usable on primitive types x.equals(y) is equality defined in runtime class of x equals relies on dynamic binding default equals is defined in class Object to be same as == equals applied to null yields a NullPointerException x.equals(null) is usually taken to be false System.identityHashCode(x) provides hashcode based on object identity of x COMP4001 CSE UNSW Sydney 4
5 Scala: object equality & hashcode x == y tests for Any equality for AnyVal objects, same as Java primitive type == for AnyRef objects, almost equivalent to x.equals(y) in Java except can test for nulls as well x == y tests for nulls then calls x.equals(y) final def == (that: Any): Boolean = if (null eq this) {null eq that else {this equals that cannot override == directly instead override the equals method x eq y is Scala's test for object identity not overridable not directly used much COMP4001 CSE UNSW Sydney 5
6 equals is usually faulty! ECOOP 2007 paper studied many Java programs most implementations of equals in Java are faulty!! I recommend reading the first 2 sections of the paper: Common errors wrong signature provides overloading instead of overriding failing to override hashcode when overriding equals defining equals in terms of mutable fields this can make sense, but limits valid uses of objects such objects cannot be used in equality/hash based searching cannot be used as elements of Sets or as keys in Maps equality in Scala's mutable collections does depend on mutable content failing to implement equals as an equivalence relation COMP4001 CSE UNSW Sydney 6
7 Wrong Signature for equals The equals method below is overloaded and wrong! class Point(val x: Int, val y: Int) { // wrong: does not override equals def equals(other: Point) = this.x == other.x && this.y == other.y COMP4001 CSE UNSW Sydney 7
8 Overriding equals We can combine overloaded and overridden versions: note use of override keyword makes difference between overriding and overloading clearer in Scala recommend always annotation in Java class Point(val x: Int, val y: Int) { // better equals, but still faulty for subclasses override def equals(other: Any) = other match { case that: Point => this equals that case _ => false def equals(that: Point) = this.x == that.x && this.y == that.y COMP4001 CSE UNSW Sydney 8
9 Asymmetric equals consider an extension to the Point class class ColoredPoint(x: Int, y: Int, val color: Color.Value) extends Point(x, y) { // equals is not symmetric override def equals(other: Any) = other match { case that: ColoredPoint => this equals that case _ => false ColoredPoint case compares Color as def equals(that: ColoredPoint) = well as coordinates this.color == that.color && super.equals(that) but this means that == is not symmetric: val p = new Point(0, 0) val red = new ColoredPoint(0, 0, Color.Red) yields p == red is true but red == p is false COMP4001 CSE UNSW Sydney 9
10 Symmetric equals to fix symmetry,in ColoredPoint we can either use a coarser equality (e.g. just use Point equals) or handle comparison of superclass objects as a special case: class ColoredPoint(x: Int, y: Int, val color: Color.Value) extends Point(x, y) { // equals is symmetric but not transitive override def equals(other: Any) = other match { case that: ColoredPoint => this equals that case that: Point => that equals this case _ => false def equals(that: ColoredPoint) = this.color == that.color && super.equals(that) extra case to handle superclass object using equals in Point COMP4001 CSE UNSW Sydney 10
11 Lack of Transitivity but this version of equals is still faulty! the definition is not transitive with p and red as before, and val blue = new ColoredPoint(0, 0, Color.Blue) we find: and p == blue is true but red == blue is false red == p is true violating the transitivity condition COMP4001 CSE UNSW Sydney 11
12 Correct overriding of equals the trick is to ensure that different objects with different versions of the equals method cannot be equal to model this correctly, need to introduce an extra method canequal(other: Point): Boolean whenever equals is overridden, ensure that canequal is too class Point(val x: Int, val y: Int) { override def equals(other: Any) = other match { case that: Point => this.equals(that) case _ => false def canequal(that: Point) = that.isinstanceof[point] final def equals(that: Point) = that.canequal(this) && (this.x == that.x) && (this.y == that.y) COMP4001 CSE UNSW Sydney 12
13 Correct overriding of equals overriding in ColouredPoint follows the same scheme class ColouredPoint(x: Int, y: Int, val colour: Colour.Value) extends Point(x, y) { override def equals(other: Any) = other match { case that: ColouredPoint => this.equals(that) case _ => false override def canequal(that: ColouredPoint) = that.isinstanceof[colouredpoint] final def equals(that: ColouredPoint) = that.canequal(this) && (this.colour == that.colour) && super.equals(that) COMP4001 CSE UNSW Sydney 13
14 Overriding HashCode if you override equals then you should also override hashcode in general you should combine super.hashcode with hashcodes or Int values of extra fields form of combination is arbitrary but usually combine 2 hashvalues using prime linear combination simple_prime * hash1 + hash2 COMP4001 CSE UNSW Sydney 14
15 Complexity of HashCode for structured objects (e.g. collections), good hashcodes usually depend on the contents of the collection so computing a hash will take time at least linear in the size of the object/collection so relying on hash-based implementations may result in slower than anticipated behaviour e.g. hashtable lookup and insertion is usually considered to be constant time but this assumes that getting the hash is a constant time computation some VMs will cache an object's hashcode to avoid such slowdowns in Scale, can force this by overriding the hashcode method as a val: override val hashcode = or override lazy val hashcode = COMP4001 CSE UNSW Sydney 15
16 Equality for Case Classes in Scala, case classes and object definitions have a default definition for equals and hashcode based on the fields of the defined object the default equals definition is an equivalence relation providing equality on all of the field types is with the defaults, equal objects are guaranteed to have the same hashcode both equals and hashcode may be overridden in which case the defaults are not supplied by the COMP4001 CSE UNSW compiler Sydney 16
17 Lecture Outline object equality design patterns composite interpreter visitor extensibility COMP4001 CSE UNSW Sydney 17
18 Design Patterns as an OO programmer you must be familiar with some standard design patterns all support my favourite dictum: program to interfaces patterns describe possible solutions to common OO design tasks provide a language for talking about designs the pattern names the intent and purpose of a group of classes in a design Gang of Four design patterns Design Patterns: Elements of Reusable OO Software Erich Gamma, Richard Helm, Ralph Johnson, John Vlissides classification of GOF patterns: creational, structural, behavioural COMP4001 CSE UNSW Sydney 18
19 Creational Patterns flexible construction of objects remove dependencies in code on implementation type Factory Method returns new objects with unknown implementation iterator() in java.util.list Abstract Factory factory methods for related types Builder piece-by-piece construction methods independent of finally constructed object implementation Scala collections use builders Prototype copy an existing object prototype-based languages Singleton use objects as "templates" add behaviours Self, Javascript, IO single instance of a class COMP4001 CSE UNSW Sydney object in Scala 19
20 Structural Patterns Decorator daisy chain objects to extend functionality synchronization wrappers in java.util.collections Adapter adapt code to new interfaces Proxy simple stub for another object Composite tree of objects also Interpreter Design Pattern Flyweight share as much of object context as possible e.g. drawing context for glyphs in GUI Façade simple interface for a whole system: "API" Bridge decouples abstraction from implementation e.g. GUI for different windowing systems COMP4001 CSE UNSW Sydney 20
21 Behavioural Patterns Template Method uses overrideable hook methods Command subclasses implement the hooks encapsulate actions, parameters, results Runnable, Callable, function objects Observer combining with Composite gives a Macro Command / Interpreter publish/subscribe observed objects only know who to notify not what the observers do Mediator controlling communication amongst peer objects State state modelled as distinct (immutable) objects Strategy plug-in different algorithms for a problem Memento support for undo Chain of Responsibility Visitor Iterator commands passed up a chain of objects e.g.contextual help in GUI abstract operation over different classes of objects standard traversal of collections COMP4001 CSE UNSW Sydney 21
22 The Composite Design Pattern hierarchical structures define recursive compositions of primitive and composite objects clients treat individual objects and compositions of objects uniformly COMP4001 CSE UNSW Sydney 22
23 The Composite Pattern acomposite: Composite aleaf: Leaf aleaf: Leaf acomposite: Composite aleaf: Leaf aleaf: Leaf aleaf: Leaf aleaf: Leaf COMP4001 CSE UNSW Sydney 23
24 Composite Structure Client Component +Operation() +Add(Component) +Remove(Component) +GetChild(int) children Leaf +Operation() Composite +Operation() +Add(Component) +Remove(Component) +GetChild(int) for all g in children g->operation() COMP4001 CSE UNSW Sydney 24
25 Composite Participants Component an object in a composition provides common interface and shared implementation provides interface for access to its child components optionally provides access to the parent component Client manipulates objects in the composition Leaf components with no children implements behaviour for primitive objects Composite components with children stores children implements child-related operations COMP4001 CSE UNSW Sydney 25
26 Consequences of Composite makes the client simple Leaf interface is subset of Composite s if identical interface, Leaf implementation needs defaults for Composite operations makes it easier to extend with new types of components design may be overly general types do not constrain the aggregation structure COMP4001 CSE UNSW Sydney 26
27 Implementation Issues in Composite explicit parent references sharing components maximising the Component interface declaring the child management operations should Component implement a list of Components? COMP4001 CSE UNSW Sydney 27
28 Implementation Issues in Composite... Child ordering Caching to improve performance Who should delete components? What's the best data structure for storing components? COMP4001 CSE UNSW Sydney 28
29 Interpreter Consider regular expressions as an example of a composite structure For example: salt & pepper cats dogs rain * raining & ( dogs cats ) * COMP4001 CSE UNSW Sydney 29
30 raining (dogs cats)* This is a parse tree How can we model this tree? COMP4001 CSE UNSW Sydney 30
31 Example Grammar regexp ::= repetition literal alternation sequence repetition ::= regexp * literal ::= identifier alternation ::= regexp regexp sequence ::= regexp regexp COMP4001 CSE UNSW Sydney 31
32 Parse Trees But how does interpret() work? COMP4001 CSE UNSW Sydney 32
33 Interpreting Expressions The interpret() call does the work at each node. LiteralExpression will check if the input matches the literal it defines, AlternationExpression will check if the input matches any of its alternatives, RepetitionExpression will check if the input has multiple copies of expression it repeats, and so on COMP4001 CSE UNSW Sydney 33
34 General Structure COMP4001 CSE UNSW Sydney 34
35 Use Interpreter when the grammar is simple efficiency is not critical often used for dynamic scripting languages query languages implementing rule interpreters to produce different kinds of output experimentation with language design COMP4001 CSE UNSW Sydney 35
36 Visitor Design Pattern when many operations need to be applied across different types of components Visitor classifies by operation rather than component avoids need to extend component classes for each operation simulates double dispatch actual method depends on component and operation type disadvantage classes have method per component hard codes component classification COMP4001 CSE UNSW Sydney 36
37 An Aside: Double Dispatch most OO languages implement dynamic binding code for method call is determined at runtime target object for call + method identifier determine which method implementation to use this is single dispatch multiple dispatch choose method based on runtime type of all call arguments e.g. in class Object: boolean equals(object o) may be specialised in subclasses but we would like to specialise code when the argument is of the same class this is an example of a binary method COMP4001 CSE UNSW Sydney 37
38 Visitor Example: parse tree every node of abstract syntax tree requires similar set of operations syntax structure is stable set of operations needs to be flexible COMP4001 CSE UNSW Sydney 38
39 Visitor Example Visitor says re-classify on basis of operations structure needs to accept visitors each node calls its (abstract) operation for the concrete visitor COMP4001 CSE UNSW Sydney 39
40 Visitor COMP4001 CSE UNSW Sydney 40
41 Visitor Collaboration Diagram COMP4001 CSE UNSW Sydney 41
42 Lecture Outline object equality design patterns composite interpreter visitor extensibility COMP4001 CSE UNSW Sydney 42
43 The Extensibility Problem Component-oriented programming software is assembled from independent components vision has not been fully realized limitations of current programming languages. A particular problem is that most Most languages have a bias towards one kind of decomposition in some languages adding new datatype variants is easy in others, adding new operations is easy Supporting both kinds of extensibility has proved itself quite elusive in FP particularly, also called the expression problem COMP4001 CSE UNSW Sydney 43
44 Issues in Extensibility must we modify existing code? problems for library code even if source is available can we retroactively extend library code? does unmodified code need recompilation? problems if source code is not available achieving separate compilation is important for large systems also for on-the-fly extensions of running systems can we independently extend existing code? COMP4001 CSE UNSW Sydney 44
45 The Extensibility Problem by example: Interpreter version of Composite result types are fixed fixed set of operations datatype is extensible pattern matching fixed set of datatypes set of operations is extensible visitor pattern OO approach to pattern matching COMP4001 CSE UNSW Sydney 45
46 The Extensibility Problem datatype extensibility + extensibility for set of operations can we achieve both together? reuse existing relationships/types without requiring recompilation of existing components can we achieve modularity? OO languages provide datatype extensibility functional programming provides extensibilility for COMP4001 CSE UNSW Sydney 46
47 Interpreter Design Pattern object Interpreter { trait Exp { def eval: Int operation is built-in not so easy to extend available operations case class Add(e1: Exp, e2: Exp) extends Exp { def eval = e1.eval + e2.eval case class Num(x: Int) extends Exp { def eval = x COMP4001 CSE UNSW Sydney 47
48 Interpreter Extensibility new forms of data are easily added no need to touch existing code new data is added as a new class implementing the Interpreter interface new operations are harder must add new operation to interface Interpreter must modify existing implementation add implementation of new operation COMP4001 CSE UNSW Sydney 48
49 Pattern-based version object Patterns { trait Exp case class Add(e1: Exp, e2: Exp) extends Exp case class Num(x: Int) extends Exp def eval(e: Exp): Int = e match { case Add(e1, e2) => eval(e1) + eval(e2) case Num(x) => x any extension to datatypes requires extra cases: not so easy to extend with extra datatypes COMP4001 CSE UNSW Sydney 49
50 Pattern-based Extensibility this is really an FP style of solution operation is defined by data structure cases so: adding a new operation is easy existing code is not modified just implement a new case-based function def adding new forms of data is harder add new case class must add a new case for each existing function modifies existing code COMP4001 CSE UNSW Sydney 50
51 Visitor-based version object Visitor { trait Exp { def accept(op: Op): Int case class Add(e1: Exp, e2: Exp) extends Exp { def accept(op: Op) = op.add(e1.accept(op), e2.accept(op)) case class Num(x: Int) extends Exp { def accept(op: Op) = op.num(x) interface for visitable components concrete components rely on visitor interface trait Op { def add(v1: Int, v2: Int) = v1 + v2 def num(x: Int) = x the visitor fixes the set of operations COMP4001 CSE UNSW Sydney 51
52 Visitor-based Extensibility the visitor is much like the pattern-based version instead of using (static) cases visitor uses a dynamic dispatch selects the concrete operation for the concrete data BUT there is a strong dependency between the form of data (Add, Num) and the Op interface the Op provides an evaluation operation for Exp adding operations is limited by the Op interface adding new forms of data is also hard must extend the Op interface re-implement all existing operations COMP4001 CSE UNSW Sydney 52
53 Generalizing the Visitor object GenericResultVisitor { trait Exp { def accept[r](op: Op[R]): R case class Add(e1: Exp, e2: Exp) extends Exp { generic result of visit def accept[r](op: Op[R]) = op.add(e1.accept(op), e2.accept(op)) case class Num(x: Int) extends Exp { def accept[r](op: Op[R]) = op.num(x) trait Op[R] { def add(v1: R, v2: R): R def num(x: Int): R COMP4001 CSE UNSW Sydney 53
54 Generic Visitor instances trait OpInt extends Op[Int] { def add(v1: Int, v2: Int) = v1 + v2 def num(x: Int) = x generic result of visit trait OpToString extends Op[String] { def add(v1: String, v2: String) = v1 + v2 def num(x: Int) = x.tostring COMP4001 CSE UNSW Sydney 54
55 Extensibility for Generic Visitor adding new types of visit operations is easy just choose the result type R implement Op[R] in a new class still adding new data is not so easy: a new case class must be defined for the data a corresponding method must be added to the Op interface and re-implemented for existing Op implementations COMP4001 CSE UNSW Sydney 55
56 Further Generalization of Visitor object GenericVisitor { trait Exp[Op[_]] { def accept[r](op: Op[R]): R case class Add[Op[R] <: AddOp[R]](e1: Exp[Op], e2: Exp[Op]) extends Exp[Op] { def accept[r](op: Op[R]) = op.add(e1.accept(op), e2.accept(op)) case class Num[Op[R] <: NumOp[R]](x: Int) extends Exp[Op] { def accept[r](op: Op[R]) = op.num(x) trait NumOp[R] { def num(x: Int): R trait AddOp[R] { def add(v1: R, v2: R): R COMP4001 CSE UNSW Sydney 56
57 Extensibility of Visitor GenericVisitor parameterizes the datatype over the set of operations Op[_] is a type constructor think of it as a kind of type function: R => Op[R] but it works on types, not values given a type R, Op[R] will be the type of operation GenericVisitor allows extension of datatype via extra subclasses of Exp independently of the set of operation of operation eg Num, Add because each datatype extension can specify its own constraints on the visitor type constructor COMP4001 CSE UNSW Sydney 57
58 Reference Modular Visitor Components A Practical Solution to the Expression Families Problem Bruno C. d. S. Oliveira ECOOP 2009 A very recent paper takes a different approach it does not rely on Scala's generics and type constructions Extensibility for the Masses Practical Extensibility with Object Algebras Bruno C. d. S. Oliveira and William R. Cook ECOOP 2012 COMP4001 CSE UNSW Sydney 58
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 informationSDC 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 informationIngegneria 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 informationDesign 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 informationIdioms and Design Patterns. Martin Skogevall IDE, Mälardalen University
Idioms and Design Patterns Martin Skogevall IDE, Mälardalen University 2005-04-07 Acronyms Object Oriented Analysis and Design (OOAD) Object Oriented Programming (OOD Software Design Patterns (SDP) Gang
More informationDESIGN 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 informationDesign Patterns. Manuel Mastrofini. Systems Engineering and Web Services. University of Rome Tor Vergata June 2011
Design Patterns Lecture 1 Manuel Mastrofini Systems Engineering and Web Services University of Rome Tor Vergata June 2011 Definition A pattern is a reusable solution to a commonly occurring problem within
More information2.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 informationTopics 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 information2.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 informationDesign 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 informationEPL 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 informationThink 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 informationObject 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 informationCSCD01 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 informationUsing 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 informationModellistica 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 informationGoals 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 informationDesign 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 informationTuesday, 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 informationSoftware 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 informationTrusted 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 informationDesign 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 informationIngegneria 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 informationIntroduction 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 informationIntroduction and History
Pieter van den Hombergh Fontys Hogeschool voor Techniek en Logistiek September 15, 2016 Content /FHTenL September 15, 2016 2/28 The idea is quite old, although rather young in SE. Keep up a roof. /FHTenL
More informationThe 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 informationProduced 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 informationadministrivia 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 informationDesign 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 informationComposite 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 informationThe 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 informationWhat 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 informationDesign 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 informationDesign 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 informationSoftware 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 informationPatterns. Erich Gamma Richard Helm Ralph Johnson John Vlissides
Patterns Patterns Pattern-based engineering: in the field of (building) architecting and other disciplines from 1960 s Some software engineers also started to use the concepts Become widely known in SE
More informationDesign 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 informationModellistica 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 8 OO modeling Design Patterns Introduction Creational Patterns Software
More informationCOSC 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 information6.3 Patterns. Definition: Design Patterns
Subject/Topic/Focus: Analysis and Design Patterns Summary: What is a pattern? Why patterns? 6.3 Patterns Creational, structural and behavioral patterns Examples: Abstract Factory, Composite, Chain of Responsibility
More informationDesign 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 informationDesign 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 informationAn 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 informationINSTITUTE OF AERONAUTICAL ENGINEERING
INSTITUTE OF AERONAUTICAL ENGINEERING (Autonomous) Dundigal, Hyderabad -500 0 COMPUTER SCIENCE AND ENGINEERING TUTORIAL QUESTION BANK Course Name : DESIGN PATTERNS Course Code : A7050 Class : IV B. Tech
More informationSocket attaches to a Ratchet. 2) Bridge Decouple an abstraction from its implementation so that the two can vary independently.
Gang of Four Software Design Patterns with examples STRUCTURAL 1) Adapter Convert the interface of a class into another interface clients expect. It lets the classes work together that couldn't otherwise
More informationProgramming Languages and Techniques (CIS120)
Programming Languages and Techniques (CIS120) Lecture 28 March 30, 2016 Collections and Equality Chapter 26 Announcements Dr. Steve Zdancewic is guest lecturing today He teaches CIS 120 in the Fall Midterm
More informationSlide 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 informationObject-Oriented Design
Object-Oriented Design Lecture 20 GoF Design Patterns Behavioral Department of Computer Engineering Sharif University of Technology 1 GoF Behavioral Patterns Class Class Interpreter: Given a language,
More informationObject 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 informationDesign 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 informationbe 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 informationLectures 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 informationTHOMAS LATOZA SWE 621 FALL 2018 DESIGN PATTERNS
THOMAS LATOZA SWE 621 FALL 2018 DESIGN PATTERNS LOGISTICS HW3 due today HW4 due in two weeks 2 IN CLASS EXERCISE What's a software design problem you've solved from an idea you learned from someone else?
More informationLast 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 informationExam 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 informationCSCD01 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 informationDesign Patterns. Manuel Mastrofini. Systems Engineering and Web Services. University of Rome Tor Vergata June 2011
Design Patterns Lecture 2 Manuel Mastrofini Systems Engineering and Web Services University of Rome Tor Vergata June 2011 Structural patterns Part 2 Decorator Intent: It attaches additional responsibilities
More informationDesign 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 informationCSCI Object Oriented Design: Frameworks and Design Patterns George Blankenship. Frameworks and Design George Blankenship 1
CSCI 6234 Object Oriented Design: Frameworks and Design Patterns George Blankenship Frameworks and Design George Blankenship 1 Background A class is a mechanisms for encapsulation, it embodies a certain
More informationSoftware Reengineering Refactoring To Patterns. Martin Pinzger Delft University of Technology
Software Reengineering Refactoring To Patterns Martin Pinzger Delft University of Technology Outline Introduction Design Patterns Refactoring to Patterns Conclusions 2 The Reengineering Life-Cycle (1)
More informationReview 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 informationDesign 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 informationInformation systems modelling UML and service description languages
Internet Engineering Tomasz Babczyński, Zofia Kruczkiewicz Tomasz Kubik Information systems modelling UML and service description languages Overview of design patterns for supporting information systems
More informationCISC 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 informationDesign 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 informationDesign Patterns IV. Alexei Khorev. 1 Structural Patterns. Structural Patterns. 2 Adapter Design Patterns IV. Alexei Khorev. Structural Patterns
Structural Design Patterns, 1 1 COMP2110/2510 Software Design Software Design for SE September 17, 2008 2 3 Department of Computer Science The Australian National University 4 18.1 18.2 GoF Structural
More informationA 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 informationPlan. 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 informationCSCD01 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 informationApplying the Observer Design Pattern
Applying the Observer Design Pattern Trenton Computer Festival Professional Seminars Michael P. Redlich (908) 730-3416 michael.p.redlich@exxonmobil.com About Myself Degree B.S. in Computer Science Rutgers
More informationObject-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 informationWhat 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 informationA Primer on Design Patterns
A Primer on Design Patterns First Edition Rahul Batra This book is for sale at http://leanpub.com/aprimerondesignpatterns This version was published on 2016-03-23 This is a Leanpub book. Leanpub empowers
More informationKeywords: 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 informationCS251 Software Engineering Lectures 18: Intro to DP
و ابتغ فيما آتاك هللا الدار اآلخرة و ال تنس نصيبك من الدنيا CS251 Software Engineering Lectures 18: Intro to DP Slides by Rick Mercer, Christian Ratliff, Oscar Nierstrasz and others 1 Outline Introduction
More informationCSCI 253. Overview. The Elements of a Design Pattern. George Blankenship 1. Object Oriented Design: Template Method Pattern. George Blankenship
CSCI 253 Object Oriented Design: George Blankenship George Blankenship 1 Creational Patterns Singleton Abstract factory Factory Method Prototype Builder Overview Structural Patterns Composite Façade Proxy
More informationSOFTWARE 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 informationTecniche 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 information3 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 informationDesign Patterns. Hausi A. Müller University of Victoria. Software Architecture Course Spring 2000
Design Patterns Hausi A. Müller University of Victoria Software Architecture Course Spring 2000 1 Motivation Vehicle for reasoning about design or architecture at a higher level of abstraction (design
More informationCHAPTER 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 informationIntroduction to Programming Using Java (98-388)
Introduction to Programming Using Java (98-388) Understand Java fundamentals Describe the use of main in a Java application Signature of main, why it is static; how to consume an instance of your own class;
More information1 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 informationAn 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 informationDesign 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 informationDesign Patterns. Observations. Electrical Engineering Patterns. Mechanical Engineering Patterns
Introduction o to Patterns and Design Patterns Dept. of Computer Science Baylor University Some slides adapted from slides by R. France and B. Tekinerdogan Observations Engineering=Problem Solving Many
More informationDay 4. COMP1006/1406 Summer M. Jason Hinek Carleton University
Day 4 COMP1006/1406 Summer 2016 M. Jason Hinek Carleton University today s agenda assignments questions about assignment 2 a quick look back constructors signatures and overloading encapsulation / information
More informationDesign 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 informationSoftware Design COSC 4353/6353 D R. R A J S I N G H
Software Design COSC 4353/6353 D R. R A J S I N G H Design Patterns What are design patterns? Why design patterns? Example DP Types Toolkit, Framework, and Design Pattern A toolkit is a library of reusable
More informationApplying 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 informationCS/CE 2336 Computer Science II
CS/CE 2336 Computer Science II UT D Session 20 Design Patterns An Overview 2 History Architect Christopher Alexander coined the term "pattern" circa 1977-1979 Kent Beck and Ward Cunningham, OOPSLA'87 used
More informationCSC207H: 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 informationApplying 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 informationCS 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 informationAPPLYING DESIGN PATTERNS TO SCA IMPLEMENTATIONS
APPLYING DESIGN PATTERNS TO SCA IMPLEMENTATIONS Adem Zumbul (TUBITAK-UEKAE, Kocaeli, Turkey, ademz@uekae.tubitak.gov.tr); Tuna Tugcu (Bogazici University, Istanbul, Turkey, tugcu@boun.edu.tr) ABSTRACT
More informationA Rapid Overview of UML
A Rapid Overview of UML The Unified dmodeling Language (UML) Emerged in the mid 90s as the de facto standard for softwareengineering engineering design Use case diagram depicts user interaction with system
More informationMVC. Model-View-Controller. Design Patterns. Certain programs reuse the same basic structure or set of ideas
MVC -- Design Patterns Certain programs reuse the same basic structure or set of ideas These regularly occurring structures have been called Design Patterns Design Patterns Design Patterns: Elements of
More informationProgramming in Scala Second Edition
Programming in Scala Second Edition Martin Odersky, Lex Spoon, Bill Venners artima ARTIMA PRESS WALNUT CREEK, CALIFORNIA Contents Contents List of Figures List of Tables List of Listings Foreword Foreword
More informationApplication 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