20 Years of. Improve the Design of your Code. Dr Dimitris Dranidis JAVA Meetup Group, Thessaloniki May 2015
|
|
- Aubrey Collins
- 5 years ago
- Views:
Transcription
1 20 Years of Design Patterns Improve the Design of your Code Dr Dimitris Dranidis JAVA Meetup Group, Thessaloniki May 2015
2 Dr Dimitris Dranidis Senior Lecturer in Computer Science Department Programme director of the MSc in Software Engineering & Telecommunications MSc in Business, Management, Technology and Innovation Leader of the "Software Engineering & Service-Oriented Technologies" research group, r Research interests: service-oriented computing, Cloud computing model-based testing, formal methods, software engineering education 2
3 Experience in software project management >10 years of management of >50 short (~3 pms) software projects Industrial Group Projects Teams of undergraduate and postgraduate students developing software for the industry Plenty of successes and failures 3
4 Experience in Java/Design Patterns Teaching Design Patterns for 15 years Advanced Software Development Techniques MSc in Software Engineering and Telecommunications Principal Developer of JSXM Model-based testing tool 14 KLOC (JSXM core) Plenty of Design Patterns applied 4
5 Your experience? Familiarity with Java? UML? Design Patterns? 5
6 Outline Quiz problem Bad smells in design Open/Closed principle Design Patterns Examples of Design Patterns Quiz solution Key points 6
7 A PROBLEM TO KEEP YOU BUSY! 7
8 Current Design ( Your current implementation of a class DocumentPrinter is as follows: class DocumentPrinter { public void printdocument(document doc) { if (doc.gettype().equals("pdf")) { PDFPrinter pdfprinter = new PDFPrinter(); pdfprinter.printpdf(doc.getcontent()); else if (doc.gettype().equals("html")) { HTMLPrinter htmlprinter = new HTMLPrinter(); htmlprinter.printhtml(doc.getcontent()); else throw new RuntimeException("Wrong type of document"); 8
9 Constraints Library classes (These classes cannot be modified). Document, PDFPrinter and HTMLPrinter You are expecting other types of documents to be handled in the future and you would not like to change your DocumentPrinter class continuously. Change DocumentPrinter once and for all! Make it open for extensions and closed to modifications! 9
10 What we wish to avoid: class DocumentPrinter { public void printdocument(document doc) { if (doc.gettype().equals("pdf")) { PDFPrinter pdfprinter = new PDFPrinter(); pdfprinter.printpdf(doc.getcontent()); else if (doc.gettype().equals("html")) { HTMLPrinter htmlprinter = new HTMLPrinter(); htmlprinter.printhtml(doc.getcontent()); else if (doc.gettype().equals( XML")) { XMLPrinter xmlprinter = new XMLPrinter(); xmlprinter.printxml(doc.getcontent()); else throw new RuntimeException("Wrong type of document"); 10
11 DESIGN SMELLS 11
12 Design smells Rigidity: Hard to change A change forces many other unforeseen changes Changing it was a lot more complicated than I thought Fragility: Easy to break A change forces the application to break in often unforeseen ways Fragile modules: The more you fix them the worst they get Immobility: Hard to reuse Useful parts are hard to separate Viscosity: Hard to do the right thing Many ways to deal with change; hacks are easier than design-preserving ways Caused by the software or the environment 12
13 Design smells Needless complexity: Overdesign Not useful (even unused) design elements Dealing with anticipated requirements Needless repetition: Cut & Paste abuse Redundant code Bugs require repetitive and different fixes Opacity: Difficult to understand Easy when you write it, difficult when you read it 13
14 OPEN-CLOSED PRINCIPLE 14
15 OCP: Open-Closed Principle A module should be Open for extension Closed for modification Client Server How can we extend the client so that it works with other servers (OPEN) without having to modify the client (CLOSED)? 15
16 OCP: Abstraction is the key! Client «interface» ClientInterface Server Bertrand Meyer 97 16
17 DESIGN PATTERNS 17
18 What are Design patterns? Well-known best design practices Named solutions to design problems by experienced developers Let s apply a Factory and a Strategy! Vocabulary of principles to design software 18
19 A Pattern Language: Towns, Buildings, Construction (1977) Book on architecture, urban design, and community livability. Patterns describe a problem and then offer a solution. Still one of the best-selling books on architecture 19
20 Gang of Four (GoF) Design Patterns (1994) 23 patterns categorized in Creational Structural Behavioral 20
21 Quotes from the Book Program to an interface, not an implementation Favor object composition over class inheritance Inheritance breaks encapsulation Implement abstract classes, do not inherit concrete classes! 21
22 22 PLoP conferences (1994-today) Pattern Languages of Programs Annual conferences *PLoP 22
23 Patterns in core Java All patterns have been implemented in Java s core libraries: /examples-of-gof-design-patternsin-javas-core-libraries or google: Examples of GoF Design Patterns in Java 23
24 DESIGN PATTERNS EXAMPLES 24
25 SHAPES EXAMPLE 25
26 Shapes example public class Rectangle { private double width; private double height; public Rectangle ( double w, double h ) { width = w ; height = h ; public double getarea() { return width * height ; 26
27 Shapes example public class AreaPrinter { private Rectangle shape; public AreaPrinter (Rectangle s ) { shape = s ; public void printarea () { System.out.println( "Shape area : " + shape.getarea() ) ; public class Main { public static void main( String arg[] ) { Rectangle rectangle = new Rectangle(2.0, 5.0); AreaPrinter ap = new AreaPrinter( rectangle ) ; ap.printarea () ; 27
28 Desired extensions We want our application to work with other types of shapes: Squares, Triangles, Circles, Polygons, etc. public class Square { private double width; public Square ( double w ) { width = w ; public double getarea() { return width * width ; Do we need another AreaPrinter for Square? Can we make AreaPrinter work for both Rectangle and Square? 28
29 Abstraction is the key! public interface Shape { public double getarea(); public class AreaPrinter { private Shape shape; public AreaPrinter ( Shape s ) { shape = s ; public void printarea () { System.out.println( "Shape area : " + shape.getarea() ) ; AreaPrinter is now open to extensions, closed to modifications! 29
30 Concrete classes implement the desired interface public class Rectangle implements Shape { private double width; private double height; public Rectangle ( double w, double h ) { width = w ; height = h ; public double getarea() { return width * height ; public class Square implements Shape { private double width; public Square ( double w ) { width = w ; public double getarea() { return width * width ; 30
31 Polygons? Polygons area is hard to calculate! We would not like to write the code ourselves. Luckily we find a class Polygon which offers the calculation of its objects area. Source code not available OR We don t wish to change the implementation of Polygon public class Polygon {... public Polygon ( List points ) {... public double computearea () { How can we integrate polygons into our Shapes application? 31
32 Adapter Design Pattern public class PolygonAdapter implements Shape { private Polygon polygon; // composition public PolygonAdapter (Polygon c ) { polygon = c ; public double getarea () { return polygon.computearea() ; // indirection 32
33 Main client public class Main { public static void main( String arg[] ) { Rectangle rectangle = new Rectangle(2.0, 5.0); AreaPrinter ap = new AreaPrinter( rectangle ) ; ap.printarea () ; Square square = new Square (3.0); AreaPrinter sp = new AreaPrinter( square ) ; sp.printarea () ; Polygon polygon = new Polygon (...); AreaPrinter pp = new AreaPrinter ( new PolygonAdapter(polygon)); pp.printarea () ; 33
34 Adapter (GoF, Structural Pattern) Intent convert the interface of an existing class into another interface used by clients Motivation: want to use an existing class but... interface of class is not compatible to the one you use and modification of class is out of question because source code of class is not available or it is a general-purpose class (you do not want to modify) resolve incompatible interfaces provide a stable interface to similar classes with different interfaces 34
35 Problem Client <<interface>> Target +request() Adaptee +specificrequest() incompatible interfaces 35
36 Adapter Solution Client <<interface>> Target +request() Adaptee +specificrequest() Adapter +request() specificrequest() 36
37 Adapter Solution Target :Client :Adapter :Adaptee 1: request() 2: specificrequest() 37
38 EMPLOYEE EXAMPLE 38
39 Current design public class Employee { private double salary ; public Employee (double s) { salary = s ; public double getpayamount () { return salary ; Assume that some privileged employees receive double salary Assume that employees can be promoted How can we extend Employee to protect it from changes? 39
40 2 possible solutions Sub-typing (Inheritance) Include a type attribute 40
41 Sub-typing solution (??) public class Manager extends Employee { public double getpayamount () { return 2 * salary ; 41
42 Sub-typing solution does not work! Objects cannot dynamically change their type An Employee object cannot be converted to a Manager object More points of variation create class explosion! Different types of employees could have different promotion eligibility criteria Leading to a huge inheritance hierarchy tree. 42
43 Type attribute solution (??) (Too smelly, violates OCP) public class Employee { private int type ; private double salary ; public static final int ENGINEER = 1; public static final int MANAGER = 2; public Employee (double s, int t) { salary = s ; type = t ; public double getpayamount () { if (type == Employee.ENGINEER) return salary; if (type == Employee.MANAGER) return salary ; return salary * 2; 43
44 Strategy Pattern solution public interface PaymentStrategy { public double getpayamount (Employee context); public class EngineerPaymentStrategy implements PaymentStrategy { public double getpayamount (Employee empl) { return empl.getsalary() ; public class ManagerPaymentStrategy implements PaymentStrategy { public double getpayamount (Employee empl) { return empl.getsalary() * 2 ; 44
45 Strategy Pattern solution public class Employee { private PaymentStrategy paymentstrategy ; // composition private double salary ; public Employee (double s, PaymentStrategy strategy) { salary = s ; paymentstrategy = strategy ; public double getsalary () {return salary ; public double getpayamount () { return paymentstrategy.getpayamount(this) ; // indirection 45
46 Strategy (GoF: Behavioral) Intent define a family of related algorithms, encapsulate each one, and make them interchangeable by providing a common interface algorithm may vary by object and also may vary over time Motivation: Many different algorithms exist for fulfilling a responsibility You need different variants of an algorithm An algorithm uses data that clients shouldn't know about A class defines many behaviors, and these appear as multiple switch statements in the classes operations Many related classes differ only in their behavior 46
47 Strategy (GoF) Motivation (cont): Separate the algorithms from the object which is using them because an object may decide to change the algorithm it uses an object will get complex if you include all the code of the algorithms an object will have to use conditionals to decide which algorithm it will use each algorithm uses its own algorithm-specific data it is difficult to add new algorithms if they are hard coded in the object. 47
48 Strategy Solution Context +contextinterface() <<interface>> Strategy +algorithminterface( context : Context ) strategy.algorithminterface(this) ConcreteStrategyA +algorithminterface( context ) ConcreteStrategyB +algorithminterface( context ) 48
49 KEY POINTS 49
50 When should you use patterns You have to add some new functionality and you find out that: You need to copy and paste code You need to hack the solution Current design does not allow easy fit of the new functionality 50
51 Protect your code from changes Identify the variation points Isolate the variation points, separate them from what is stable. Encapsulate variations in a method/class method encapsulation Template method, Factory method class encapsulation Strategy, Abstract Factory 51
52 When NOT to use Design Patterns Patterns introduce complexity Simple problems require simple solutions Over-conformance to good design principles leads to Needless Complexity Apply Design Patterns only when it is necessary! Remember: Not everything is a nail! 52
53 SOLUTION TO PROBLEM 53
54 Current Design ( class DocumentPrinter { public void printdocument(document doc) { if (doc.gettype().equals("pdf")) { PDFPrinter pdfprinter = new PDFPrinter(); pdfprinter.printpdf(doc.getcontent()); else if (doc.gettype().equals("html")) { HTMLPrinter htmlprinter = new HTMLPrinter(); htmlprinter.printhtml(doc.getcontent()); else throw new RuntimeException("Wrong type of document"); 54
55 Analysis of the problem Variation points: Objects created: PDFPrinter pdfprinter = new PDFPrinter(); HTMLPrinter htmlprinter = new HTMLPrinter(); Interface of objects: pdfprinter.printpdf(doc.getcontent()); htmlprinter.printhtml(doc.getcontent()); 55
56 Adapter (Providing a stable interface) public interface Printer { public void print (String content); public class PDFPrinterAdapter implements Printer { public void print (String content) { PDFPrinter pdfprinter = new PDFPrinter(); pdfprinter.printpdf(content); similar for HTMLPrinterAdapter 56
57 Factory (GoF Creational) (Provides a stable interface for object creation) public class PrinterFactory { Printer makeprinter (String doctype) { if (doctype.equals("pdf")) { return new PDFPrinterAdapter(); else if (doctype.equals("html")) { return new HTMLPrinterAdapter() else throw new RuntimeException(" "); 57
58 Singleton (GoF Creational) public class PrinterFactory { static PrinterFactory printerfactory = new PrinterFactory(); protected PrinterFactory() { static PrinterFactory getinstance() { return printerfactory; Printer makeprinter(string doctype) {. 58
59 Final DocumentPrinter (Open for extensions, closed for modifications) class DocumentPrinter { public void printdocument(document doc) { PrinterFactory printerfactory = PrinterFactory.getInstance(); Printer printer = printerfactory.makeprinter (doc.gettype()); printer.print (doc.getcontent()); 59
60 or as one-liner! class DocumentPrinter { public void printdocument(document doc) { PrinterFactory.getInstance().makePrinter (doc.gettype()). print (doc.getcontent()); 60
61 How to learn Design Patterns Pick a pattern and then find, and read as many examples as possible Focus on the problems the patterns solves, NOT the solution! Invent your own examples/problems Apply the Design Pattern and enjoy! 61
62 How to apply Design Patterns Follow a problem-directed approach: Identification of the pattern needed: understand the problem find a pattern that addresses the problem (or a similar problem) Study the Pattern solution UML diagrams code example (C++, Java, ) Apply the solution to the problem embed pattern name in class/method names 62
63 Recommended Readings Design Patterns, GoF Refactoring, Martin Fowler Agile Software Development, Robert Martin Avoid all the Design Patterns in XXX++## books! 63
64 Thank you! Questions? 64
Outline. Software Rots
Outline Design Principles: Part 1 ENGI 5895: Software Design 1 The Need for Design Principles Andrew Vardy 2 Refactoring Faculty of Engineering & Applied Science Memorial University of Newfoundland January
More informationIngegneria del Software Corso di Laurea in Informatica per il Management. Software quality and Object Oriented Principles
Ingegneria del Software Corso di Laurea in Informatica per il Management Software quality and Object Oriented Principles Davide Rossi Dipartimento di Informatica Università di Bologna Design goal The goal
More informationLecture 13: Design Patterns
1 Lecture 13: Design Patterns Kenneth M. Anderson Object-Oriented Analysis and Design CSCI 6448 - Spring Semester, 2005 2 Pattern Resources Pattern Languages of Programming Technical conference on Patterns
More informationPattern Resources. Lecture 25: Design Patterns. What are Patterns? Design Patterns. Pattern Languages of Programming. The Portland Pattern Repository
Pattern Resources Lecture 25: Design Patterns Kenneth M. Anderson Object-Oriented Analysis and Design CSCI 6448 - Spring Semester, 2003 Pattern Languages of Programming Technical conference on Patterns
More informationDesign to interfaces. Favor composition over inheritance Find what varies and encapsulate it
Design Patterns The Gang of Four suggests a few strategies for creating good o-o designs, including Façade Design to interfaces. Favor composition over inheritance Find what varies and encapsulate it One
More 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 informationCPSC 310 Software Engineering. Lecture 11. Design Patterns
CPSC 310 Software Engineering Lecture 11 Design Patterns Learning Goals Understand what are design patterns, their benefits and their drawbacks For at least the following design patterns: Singleton, Observer,
More information2/17/04 Doc 8 Adapter & Strategy slide # 1
2/17/04 Doc 8 Adapter & Strategy slide # 1 CS 635 Advanced Object-Oriented Design & Programming Spring Semester, 2004 Doc 8 Adapter & Strategy Contents Adapter...2 Motivating Adapter...2 Adapter...6 Consequences...10
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 informationOODP Session 4. Web Page: Visiting Hours: Tuesday 17:00 to 19:00
OODP Session 4 Session times PT group 1 Monday 18:00 21:00 room: Malet 403 PT group 2 Thursday 18:00 21:00 room: Malet 407 FT Tuesday 13:30 17:00 room: Malet 404 Email: oded@dcs.bbk.ac.uk Web Page: http://www.dcs.bbk.ac.uk/~oded
More informationOutline. 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 informationn HW5 out, due Tuesday October 30 th n Part 1: Questions on material we ll cover today n Part 2: BFS using your graph from HW4
Subtype, Subtyping vs. Subclassing, Liskov Substitution Principle Announcements n HW5 out, due Tuesday October 30 th n Part 1: Questions on material we ll cover today n Part 2: BFS using your graph from
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 informationOpen Closed Principle (OCP)
Open Closed Principle (OCP) Produced by: Eamonn de Leastar (edeleastar@wit.ie) Dr. Siobhán Drohan (sdrohan@wit.ie) Department of Computing and Mathematics http://www.wit.ie/ SOLID Class Design Principles
More informationOO Class Design Principles
3.3 Class Design Principles Single Responsibility Principle (SRP) Open/Closed Principle (OCP) Liskov Substitution Principle (LSP) a.k.a. Design by Contract Dependency Inversion Principle (DIP) Interface
More informationInheritance and Encapsulation. Amit Gupta
Inheritance and Encapsulation Amit Gupta Project 1 How did it go? What did you like about it? What did you not like? What can we do to help? Suggestions Ask questions if you don t understand a concept
More informationObject Oriented Design and Programming Revision
M.Sc Computer Science Object Oriented Design and Programming Revision Oded Lachish Email: oded@dcs.bbk.ac.uk Web Page: http://www.dcs.bbk.ac.uk/~oded/oodp12/oodp2012.html Question 1 (a) What is the motivation
More informationObject Design Guidelines
Object Design Guidelines 1 / 17 Design Smells Rigidity system is too hard to change becuase change in one place forces changes in many other places Fragility changes break things that are conceptually
More informationExpanding Our Horizons. CSCI 4448/5448: Object-Oriented Analysis & Design Lecture 9 09/25/2011
Expanding Our Horizons CSCI 4448/5448: Object-Oriented Analysis & Design Lecture 9 09/25/2011 1 Goals of the Lecture Cover the material in Chapter 8 of our textbook New perspective on objects and encapsulation
More informationPrinciples of OO Design
Principles of OO Design Ing. Libor Buš PhD. Department of Software Engineering Faculty of Information Technology Czech Technical University in Prague MI-DPO WS 2010/11, Lecture 1 Evropský sociální fond
More informationMSO Lecture 6. Wouter Swierstra. September 24, 2015
1 MSO Lecture 6 Wouter Swierstra September 24, 2015 2 LAST LECTURE Case study: CAD/CAM system What are design patterns? Why are they important? What are the Facade and Adapter patterns? 3 THIS LECTURE
More 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 informationMore on Design. CSCI 5828: Foundations of Software Engineering Lecture 23 Kenneth M. Anderson
More on Design CSCI 5828: Foundations of Software Engineering Lecture 23 Kenneth M. Anderson Outline Additional Design-Related Topics Design Patterns Singleton Strategy Model View Controller Design by
More 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 informationOODP Session 5a. Web Page: Visiting Hours: Tuesday 17:00 to 19:00
OODP Session 5a Next week: Reading week Session times PT group 1 Monday 18:00 21:00 room: Malet 403 PT group 2 Thursday 18:00 21:00 room: Malet 407 FT Tuesday 13:30 17:00 room: Malet 404 Email: oded@dcs.bbk.ac.uk
More informationDesign Patterns: State, Bridge, Visitor
Design Patterns: State, Bridge, Visitor State We ve been talking about bad uses of case statements in programs. What is one example? Another way in which case statements are sometimes used is to implement
More informationObject Oriented Software Design - I
Object Oriented Software Design - I Object Oriented Design Principles Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa October 28, 2011 G. Lipari (Scuola Superiore Sant Anna)
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 informationData Structures (INE2011)
Data Structures (INE2011) Electronics and Communication Engineering Hanyang University Haewoon Nam ( hnam@hanyang.ac.kr ) Lecture 1 1 Data Structures Data? Songs in a smartphone Photos in a camera Files
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 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 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 informationFacade and Adapter. Comp-303 : Programming Techniques Lecture 19. Alexandre Denault Computer Science McGill University Winter 2004
Facade and Adapter Comp-303 : Programming Techniques Lecture 19 Alexandre Denault Computer Science McGill University Winter 2004 March 23, 2004 Lecture 19 Comp 303 : Facade and Adapter Page 1 Last lecture...
More 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 informationChapter 10 Classes Continued. Fundamentals of Java
Chapter 10 Classes Continued Objectives Know when it is appropriate to include class (static) variables and methods in a class. Understand the role of Java interfaces in a software system and define an
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 informationSoftware Engineering Prof. Rushikesh K.Joshi IIT Bombay Lecture-15 Design Patterns
Software Engineering Prof. Rushikesh K.Joshi IIT Bombay Lecture-15 Design Patterns Today we are going to talk about an important aspect of design that is reusability of design. How much our old design
More informationIntroduction to Object Oriented Programming. (Hebrew University, CS / Spring 2012 )
Introduction to Object Oriented Programming (Hebrew University, CS 67125 / Spring 2012 ) Overview There are many important Object Oriented Design (OOD) principles Today we'll focus on several basic principles
More informationHighlights of Previous Lecture
Highlights of Previous Lecture Final Project Goals 1. Set up collections of Flights 2. Maintain information about reservation availability on flights 3. Respond to reservation requests 4. Set up collections
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 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 informationA A B U n i v e r s i t y
A A B U n i v e r s i t y Faculty of Computer Sciences O b j e c t O r i e n t e d P r o g r a m m i n g Week 10: I n h e r i t a n c e Asst. Prof. Dr. M entor Hamiti mentor.hamiti@universitetiaab.com
More informationPrinciples of Object-Oriented Design
Principles of Object-Oriented Design 1 The Object-Oriented... Hype What are object-oriented (OO) methods? OO methods provide a set of techniques for analysing, decomposing, and modularising software system
More informationC18a: Abstract Class and Method
CISC 3115 TY3 C18a: Abstract Class and Method Hui Chen Department of Computer & Information Science CUNY Brooklyn College 10/31/2018 CUNY Brooklyn College 1 Outline Recap Inheritance and polymorphism Abstract
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 informationIntroduction 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 informationExam Questions. Object-Oriented Design, IV1350. Maximum exam score is 100, grade limits are as follows. Score Grade 90 A 80 B 70 C 60 D 50 E
Object-Oriented Design, IV1350 Maximum exam score is 100, grade limits are as follows. Score Grade 90 A 80 B 70 C 60 D 50 E The exam questions will be a subset of the questions below. The exam may contain
More informationCPSC 310: Sample Final Exam Study Questions 2014S1 (These are in addition to the Study Questions listed at the end of some lectures)
CPSC 310: Sample Final Exam Study Questions 2014S1 (These are in addition to the Study Questions listed at the end of some lectures) 1. Select the best functional requirement from the list of requirements
More informationCS 370 Design Heuristics D R. M I C H A E L J. R E A L E F A L L
CS 370 Design Heuristics D R. M I C H A E L J. R E A L E F A L L 2 0 1 5 Introduction Now we ll talk about ways of thinking about design Guidelines for trials in trial and errors Major Design Heuristics
More informationDesign 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 informationA - 1. CS 494 Object-Oriented Analysis & Design. UML Class Models. Overview. Class Model Perspectives (cont d) Developing Class Models
CS 494 Object-Oriented Analysis & Design UML Class Models Overview How class models are used? Perspectives Classes: attributes and operations Associations Multiplicity Generalization and Inheritance Aggregation
More informationDesign patterns. Jef De Smedt Beta VZW
Design patterns Jef De Smedt Beta VZW Who Beta VZW www.betavzw.org Association founded in 1993 Computer training for the unemployed Computer training for employees (Cevora/Cefora) 9:00-12:30 13:00-16:00
More informationCS 2340 Objects and Design
CS 2340 Objects and Design Software Design Christopher Simpkins chris.simpkins@gatech.edu Chris Simpkins (Georgia Tech) CS 2340 Objects and Design Software Design 1 / 6 Design Design (noun) A plan or protocol
More informationBruno Bossola SOLID Design Principles
Bruno Bossola SOLID Design Principles About me C Developer since 1988 Java developer since 1996 XP Coach during 2000 2001 Lead coordinator and co founder of JUG Torino in 2001 Sun Java Champion since 2005
More informationMSO Lecture 6. Wouter Swierstra (adapted by HP) September 28, 2017
1 MSO Lecture 6 Wouter Swierstra (adapted by HP) September 28, 2017 2 LAST LECTURE Case study: CAD/CAM system What are design patterns? Why are they important? What are the Facade and Adapter patterns?
More 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 information17.11 Bean Rules persistent
17.10 Java Beans Java beans are a framework for creating components in Java. AWT and Swing packages are built within this framework Made to fit in with graphic development environments such as Jbuilder
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 informationObject-oriented programming. and data-structures CS/ENGRD 2110 SUMMER 2018
Object-oriented programming 1 and data-structures CS/ENGRD 2110 SUMMER 2018 Lecture 4: OO Principles - Polymorphism http://courses.cs.cornell.edu/cs2110/2018su Lecture 3 Recap 2 Good design principles.
More informationObject-Oriented Design
Object-Oriented Design Lecture 14: Design Workflow Department of Computer Engineering Sharif University of Technology 1 UP iterations and workflow Workflows Requirements Analysis Phases Inception Elaboration
More informationAgile Principles, Patterns, and Practices in C#
Agile Principles, Patterns, and Practices in C# Robert C. Martin Micah Martin 22 Upper Saddle River, NJ Boston Indianapolis San Francisco New York Toronto Montreal London Munich Paris Madrid!ENTICE,,,.
More informationPrinciples of Ruby Applica3on Design. Dean Wampler Senior Mentor and Consultant Object Mentor, Inc. Chicago, IL
Principles of Ruby Applica3on Design Dean Wampler Senior Mentor and Consultant Object Mentor, Inc. Chicago, IL dean@objectmentor.com 1 Get the latest version of this talk: aspectprogramming.com/papers
More informationProctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.
SOLUTION HAND IN Answers Are Recorded on Question Paper QUEEN'S UNIVERSITY SCHOOL OF COMPUTING CISC212, FALL TERM, 2006 FINAL EXAMINATION 7pm to 10pm, 19 DECEMBER 2006, Jeffrey Hall 1 st Floor Instructor:
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 informationProctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.
HAND IN Answers Are Recorded on Question Paper QUEEN'S UNIVERSITY SCHOOL OF COMPUTING CISC212, FALL TERM, 2006 FINAL EXAMINATION 7pm to 10pm, 19 DECEMBER 2006, Jeffrey Hall 1 st Floor Instructor: Alan
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 informationOn Polymorphism and the Open-Closed Principle
Berner Fachhochschule Engineering and Information Technology On Polymorphism and the Open-Closed Principle Prof. Dr. Eric Dubuis Berner Fachhochschule, Engineering and Information Technology @ Biel Course
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 informationCredit where Credit is Due. Lecture 25: Refactoring. Goals for this lecture. Last Lecture
Credit where Credit is Due Lecture 25: Refactoring Kenneth M. Anderson Object-Oriented Analysis and Design CSCI 6448 - Spring Semester, 2002 Some of the material for this lecture and lecture 26 is taken
More informationAgile Architecture. The Why, the What and the How
Agile Architecture The Why, the What and the How Copyright Net Objectives, Inc. All Rights Reserved 2 Product Portfolio Management Product Management Lean for Executives SAFe for Executives Scaled Agile
More informationEssential Skills for the Agile Developer. Agile. copyright Net Objectives, Inc.
Essential Skills for the Agile Developer Agile copyright 2010. Net Objectives, Inc. Lean for Executives Product Portfolio Management Business Lean Enterprise ASSESSMENTS CONSULTING TRAINING COACHING Team
More informationPlan. 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 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 informationCSCI 528: OBJECT ORIENTED PROGRAMMING, Fall 2015
CSCI 528: OBJECT ORIENTED PROGRAMMING, Fall 2015 INSTRUCTOR: Dr. Ray Maleh Adjunct Professor, Department of Computer Science Office: TBD Email: Ray_Maleh@tamuc.edu Office Hours: Mondays 7:10 PM 8:10 PM,
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 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 informationvoid printowing(double amount) { printbanner(); printdetails(); void printdetails(double amount) {
Refactoring References: Martin Fowler, Refactoring: Improving the Design of Existing Code; ; Bruce Wampler, The Essence of Object-Oriented Oriented Programming with Java and UML A recent OO technique that
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 informationCREATED BY: Muhammad Bilal Arslan Ahmad Shaad. JAVA Chapter No 5. Instructor: Muhammad Naveed
CREATED BY: Muhammad Bilal Arslan Ahmad Shaad JAVA Chapter No 5 Instructor: Muhammad Naveed Muhammad Bilal Arslan Ahmad Shaad Chapter No 5 Object Oriented Programming Q: Explain subclass and inheritance?
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 informationBridge Pattern. Used to decouple an abstraction from its implementation so that the two can vary independently
Bridge Pattern Used to decouple an abstraction from its implementation so that the two can vary independently What that means Abstraction and implementation are not related in the sense that the implementation
More informationPlan. 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 informationProgrammazione. Prof. Marco Bertini
Programmazione Prof. Marco Bertini marco.bertini@unifi.it http://www.micc.unifi.it/bertini/ Design patterns Design patterns are bug reports against your programming language. - Peter Norvig What are design
More informationWelcome to Design Patterns! For syllabus, course specifics, assignments, etc., please see Canvas
Welcome to Design Patterns! For syllabus, course specifics, assignments, etc., please see Canvas What is this class about? While this class is called Design Patterns, there are many other items of critical
More informationEvolving Software. CMSC 433 Programming Language Technologies and Paradigms Spring Example. Some Motivations for This Refactoring
CMSC 433 Programming Language Technologies and Paradigms Spring 2007 Refactoring April 24, 2007 Lots of material taken from Fowler, Refactoring: Improving the Design of Existing Code 1 Evolving Software
More informationInheritance and Polymorphism
Object Oriented Programming Designed and Presented by Dr. Ayman Elshenawy Elsefy Dept. of Systems & Computer Eng.. Al-Azhar University Website: eaymanelshenawy.wordpress.com Email : eaymanelshenawy@azhar.edu.eg
More informationAgile Software Development
Agile Software Development Principles, Patterns, and Practices Robert Cecil Martin Alan Apt Series Prentice Hall Pearson Education, Inc. Upper Saddle River, New Jersey 07458 Foreword Preface About the
More informationCS560. Lecture: Design Patterns II Includes slides by E. Gamma et al., 1995
CS560 Lecture: Design Patterns II Includes slides by E. Gamma et al., 1995 Classification of GoF Design Pattern Creational Structural Behavioural Factory Method Adapter Interpreter Abstract Factory Bridge
More informationSoftware Engineering Design & Construction Dr. Michael Eichberg Fachgebiet Softwaretechnik Technische Universität Darmstadt
Summer Term 2018 Software Engineering Design & Construction Dr. Michael Eichberg Fachgebiet Softwaretechnik Technische Universität Darmstadt Open-Closed Principle Extension: Extending the behavior of a
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 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 informationSoftware Reengineering P1: Intro & Organization. Martin Pinzger Delft University of Technology
Software Reengineering P1: Intro & Organization Martin Pinzger Delft University of Technology Greenfield software development 2 Non-greenfield software development? 3 How often did you...... encounter
More informationAbstract Classes. Abstract Classes a and Interfaces. Class Shape Hierarchy. Problem AND Requirements. Abstract Classes.
a and Interfaces Class Shape Hierarchy Consider the following class hierarchy Shape Circle Square Problem AND Requirements Suppose that in order to exploit polymorphism, we specify that 2-D objects must
More informationAdministrivia. Programming Language Fall Example. Evolving Software. Project 3 coming out Midterm October 28. Refactoring October 14, 2004
CMSC 433 Programming Language Fall 2004 Project 3 coming out Midterm October 28 Administrivia Refactoring October 14, 2004 Lots of material taken from Fowler, Refactoring: Improving the Design of Existing
More informationCSE 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 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 informationCS 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 informationThe Design Patterns Matrix From Analysis to Implementation
The Design Patterns Matrix From Analysis to Implementation This is an excerpt from Shalloway, Alan and James R. Trott. Design Patterns Explained: A New Perspective for Object-Oriented Design. Addison-Wesley
More informationLast class. -More on polymorphism -super -Introduction to interfaces
Last class -More on polymorphism -super -Introduction to interfaces Interfaces Sometimes in Java, we will have 2 classes that both share a similar structure, but neither of them is clearly the parent or
More informationCMSC 132: Object-Oriented Programming II. Inheritance
CMSC 132: Object-Oriented Programming II Inheritance 1 Mustang vs Model T Ford Mustang Ford Model T 2 Interior: Mustang vs Model T 3 Frame: Mustang vs Model T Mustang Model T 4 Compaq: old and new Price:
More information