TO DO: Create a new class which adds statistics to the dice. NOTE: Don t forget to run regression tests
|
|
- Jonathan Ellis
- 5 years ago
- Views:
Transcription
1 TO DO: Create a new class which adds statistics to the dice This class should add functionality to store the roll frequencies. You should implement a validation test (as well as running unit tests) as below: NOTE: Don t forget to run regression tests 2013: J Paul Gibson TSP: Object Oriented Development CSC7322/DesignII.1
2 TO DO: Implement 2 different designs //using inheritance public class DiceWithStatistics1 extends Dice implements DiceWithStatisticsSpecification{ // //using composition public class DiceWithStatistics2 implements DiceWithStatisticsSpecification{ // protected Dice dice; // If you have not developed your own solution code then you should try to understand my sample solution, which can be downloaded from the module web site: Dice-WithStatistics.zip 2013: J Paul Gibson TSP: Object Oriented Development CSC7322/DesignII.2
3 Specification using an interface package abstractions; public interface DiceWithStatisticsSpecification extends DiceSpecification{ public abstract int frequencyofroll(int side) throws IllegalArgumentException; public abstract boolean invariant(); public abstract void roll(); public String tostring(); Note: Javadoc comments not on the transparency, but included in the code are used to update the documentation for the statistics specification 2013: J Paul Gibson TSP: Object Oriented Development CSC7322/DesignII.3
4 TO DO: Implementation using inheritance * * This class extends the behaviour of the {@link Dice with * statistics for frequency of rolls<br> * These statistics are viewable through an updated tostring method * J Paul Gibson 1 <br> * <ul> * <li> Design decision - use inheritance to extend already existing Dice behaviour </li> * <li> Implementation decision - store the roll frequencies in an array of integers </li> * </ul> public class DiceWithStatistics1 extends Dice implements DiceWithStatisticsSpecification { * Stores the number of times each side of the dice has been rolled protected int rollsfrequency []; 2013: J Paul Gibson TSP: Object Oriented Development CSC7322/DesignII.4
5 TO DO: Implementation using inheritance * Create a default dice and reset the roll frequencies for each side to be 0<br> * Increment the count for the <code> numberofdiewithstatistics</code> public DiceWithStatistics1 (){ super(); rollsfrequency = new int [NUMBEROFSIDES]; resetfrequencies(); numberofdiewithstatistics++; * Create a dice and reset the roll frequencies for each side to be 0<br> * Increment the count for the <code> numberofdiewithstatistics</code> sides can specify the number of sides * (within range of {@link DiceSpecification#MINIMUM_numberOfSides.. * {@link DiceSpecification#MAXIMIM_numberOfSides) public DiceWithStatistics1 (int sides){ super(sides); rollsfrequency = new int [NUMBEROFSIDES]; resetfrequencies(); numberofdiewithstatistics++; 2013: J Paul Gibson TSP: Object Oriented Development CSC7322/DesignII.5
6 TO DO: Implementation using inheritance public boolean invariant(){ if (rollsfrequency==null ) return false; if (rollsfrequency.length < NUMBEROFSIDES) return false; for (int i =0; i<numberofsides; i++) if (rollsfrequency[i] <0) return false; return super.invariant(); QUESTION: Could/Should this invariant be implemented in an abstract class? 2013: J Paul Gibson TSP: Object Oriented Development CSC7322/DesignII.6
7 TO DO: Implementation using inheritance * rolls the dice, updates the lastroll value and updates the frequency history public void roll(){ super.roll(); rollsfrequency[lastroll()-1] = rollsfrequency[lastroll()-1]+1; the number of times the dice has rolled the specified side side specifies the side of the dice for which we wish to know * the number of rolls public int frequencyofroll(int side) throws IllegalArgumentException{ if (side <=0 side > MAXIMIM_numberOfSides) throw (new IllegalArgumentException("The number of sides specified is not valid")); return rollsfrequency[side-1]; 2013: J Paul Gibson TSP: Object Oriented Development CSC7322/DesignII.7
8 TO DO: Implementation using inheritance a string representation of the current dice state, * including statistics public String tostring(){ String str = super.tostring(); str = str+"\n Frequencies:\n"; for (int i =0; i<dice.numberofsides(); i++) str=str+"("+(i+1)+", "+rollsfrequency[i]+")"; str=str+"\n"; return str; QUESTION: Could/Should this method be implemented in an abstract class? 2013: J Paul Gibson TSP: Object Oriented Development CSC7322/DesignII.8
9 TO DO: Implementation using composition * * This class extends the behaviour of the {@link Dice with statistics for * frequency of rolls<br> * These statistics are readable through the tostring method * J Paul Gibson 1 <br> * <ul> * <li> Design decision - use composition to re-use already existing Dice behaviour </li> * <li> Implementation decision - store the roll frequencies in an array of integers </li> * </ul> public class DiceWithStatistics2 implements DiceSpecification{ protected Dice dice; * The number of diewithstatistics objects that are currently instantiated<br> * We decrement this value when a DiceWithStatistics1 destructor is called - protected static int numberofdiewithstatistics = 0; * Stores the number of times each side of the dice has been rolled protected int rollsfrequency []; 2013: J Paul Gibson TSP: Object Oriented Development CSC7322/DesignII.9
10 TO DO: Implementation using composition * Create a new DiceWithStatistics2 and reset the roll frequencies for each side to be 0<br> * The number of sides is set by default to {@link DiceSpecification#DEFAULT_numberOfSides<br> * Increment the count for the <code> numberofdiewithstatistics</code> public DiceWithStatistics2 (){ dice = new Dice(); rollsfrequency = new int [dice.numberofsides()]; resetfrequencies(); numberofdiewithstatistics++; * Create a new DiceWithStatistics2 and reset the roll frequencies for each side to be 0<br> * Increment the count for the <code> numberofdiewithstatistics</code> sides can specify the number of sides * (within range of {@link DiceSpecification#MINIMUM_numberOfSides.. * {@link DiceSpecification#MAXIMIM_numberOfSides) * <br> If it is not in range use the default number of sides ({@link DiceSpecification#DEFAULT_numberOfSides) public DiceWithStatistics2 (int sides){ dice = new Dice(sides); rollsfrequency = new int [dice.numberofsides()]; resetfrequencies(); numberofdiewithstatistics++; 2013: J Paul Gibson TSP: Object Oriented Development CSC7322/DesignII.10
11 TO DO: Implementation using composition public int lastroll (){ return dice.lastroll(); public int numberofsides(){ return dice.numberofsides(); public int numberofrolls(){ return dice.numberofrolls(); * Decrement the count for the number of current DiceWithStatistics that are instantiated protected void finalize() throws Throwable{ numberofdiewithstatistics--; 2013: J Paul Gibson TSP: Object Oriented Development CSC7322/DesignII.11
12 TO DO: Implementation using composition public boolean invariant(){ if (rollsfrequency==null ) dice.invariant(); else for (int i =0; i<dice.numberofsides(); i++) if (rollsfrequency[i] <0) return false; return true; public void roll(){ dice.roll(); rollsfrequency[lastroll()-1] = rollsfrequency[lastroll()-1]+1; public int frequencyofroll(int side) throws IllegalArgumentException{ if (side <=0 side > numberofsides()) throw (new IllegalArgumentException("The number of sides specified is not valid")); return rollsfrequency[side-1]; 2013: J Paul Gibson TSP: Object Oriented Development CSC7322/DesignII.12
13 TO DO: Implementation using composition a string representation of the current dice state, including statistics public String tostring(){ String str = dice.tostring(); str = str+"\n Frequencies: \n"; for (int i =0; i<dice.numberofsides(); i++) str=str+"("+(i+1)+", "+rollsfrequency[i]+")"; str=str+"\n"; return str; Note: this is very similar to the tostring method in the inheritance based design a string representation of the current dice state, * including statistics public String tostring(){ String str = super.tostring(); str = str+"\n Frequencies: \n"; for (int i =0; i<dice.numberofsides(); i++) str=str+"("+(i+1)+", "+rollsfrequency[i]+")"; str=str+"\n"; return str; QUESTION: how to factor out the cut-and-paste code? 2013: J Paul Gibson TSP: Object Oriented Development CSC7322/DesignII.13
14 TO DO: Write tests for both designs Unit tests Validation tests Maximise re-use Maximise re-usability Minimize cut-and-paste programming 2013: J Paul Gibson TSP: Object Oriented Development CSC7322/DesignII.14
15 TO DO: Create 2 different terminal/console views The frequencies can either be displayed vertically or horizontally. (OPTIONAL: If the frequency values are bigger than the height/width of the screen then you should scale them in order to occupy as much of the screen as possible. The screen size should be stored in constant variables HEIGHT and WIDTH.) 1 ******** 2 ****** 3 *** 4 **** 5 ****** 6 ** 7 *** 8 ** 9 ***** ***** 12 ** 13 ******** 14 ***** 15 ********* * * * * * * * * * * * * * * * * * * * * ** * * * ** * * * ** * * * *** ** ** * * *** ** ** * * *** ***** * * * *** ***** * * * *** ********* ***** ********* ***** ********* ***** ********* ***** ********* ***** DISCUSSION: How to best include these views in the design? 2013: J Paul Gibson TSP: Object Oriented Development CSC7322/DesignII.15
16 The consequences of the initial design decision Choosing to implement a DiceWithStatistics as a subclass of Dice is a design decision that may have consequencies on later stages of the development. The alternative re-use mechanism was to design a DiceWithStatistics class/object to have a Dice component class/object. This also may have consequencies on later stages of the development DISCUSSION: What are the possible consequences (positive and negative)? CLUE: You may have seen them when we considered the different views OBSERVERS: We may wish to create different views that automatically update when the state of the models changes 2013: J Paul Gibson TSP: Object Oriented Development CSC7322/DesignII.16
17 The Observer Design Pattern This pattern is among the most useful for object-oriented software design. It is a key part of the MVC pattern - the JDK itself makes heavy use of a variant of this pattern in the 1.1 AWT event delegation model, and the Swing libraries also facilitate its use The JDK libraries also provide a reusable implementation of the pattern in the form of the java.util.observer interface and the java.util.observable class. 2013: J Paul Gibson TSP: Object Oriented Development CSC7322/DesignII.17
18 The Observer Design Pattern: UML The idea of the pattern is to model a one-to-many dependency without tightly coupling the observed object with its many observers. When the observed object changes in some interesting way it can automatically notify all of its observers without knowing them directly 2013: J Paul Gibson TSP: Object Oriented Development CSC7322/DesignII.18
19 Weaknesses Unfortunately, a number of weaknesses have been identified in the JDK's Observer/Observable classes. These weaknesses significantly limit the reusability and power of the classes, which is a shame since powerful reusability is a big part of what object oriented design is all about. Most of the weaknesses are due to the fact that java.util.observable is a class rather than an interface; or rather, that it is a class without a corresponding interface. This implies that the only way to reuse Observable is to subclass it. You can't take an existing class and tack on the role of Observable by having it implement an Observable interface because there is no Observable interface. 2013: J Paul Gibson TSP: Object Oriented Development CSC7322/DesignII.19
20 Weaknesses What if you have a class that is already in a class hierarchy and also needs to play the role of an Observable? Since Java doesn't support multiple inheritance, you're out of luck. That class cannot extend from Observable because it is already extending from some other class. It also means that you are stuck with the one and only implementation of Observable in java.util.observable. For a variety of reasons, you may want to use an alternate implementation - e.g., to do the notification in a separate thread or in a particular order. You may even want to vary the implementation of Observable at runtime. There is no Observable interface for your alternate implementations to implement. You cannot reuse Observable by composition so you cannot vary the composed Observable implementation at runtime. 2013: J Paul Gibson TSP: Object Oriented Development CSC7322/DesignII.20
21 Weaknesses The designers of the Observable class broke two general principles of objectoriented design with Java: 1. The first principle is to design with interfaces rather than classes. Whenever possible, avoid committing yourself to a particular implementation of an interface. 2. The second principle is to favor reuse by composition over reuse by inheritance unless a class hierarchy is clearly indicated. By omitting an Observable interface and making some of its methods protected, the designers made it impossible to reuse Observable by composition. 2013: J Paul Gibson TSP: Object Oriented Development CSC7322/DesignII.21
22 Weaknesses A minor weakness in Observable is the necessity to call setchanged() before notifysubscribers(). The intention there seems to be to eliminate needless notifications in cases where there is no interesting change to the Observable. There may be situations in which this two-stage notification is appropriate, but it isn't the simplest case and programmers shouldn't be forced to use this implementation in all situations. Also, setchanged() is protected, further reinforcing the necessity to reuse the class only by inheritance. 2013: J Paul Gibson TSP: Object Oriented Development CSC7322/DesignII.22
23 Weaknesses The main weakness in the Observer interface is its tight coupling with the Observable class. The first parameter to the update() method is unnecessarily typed as an Observable. If it were typed more generally as a simple Object, the Observer interface would be more reusable. It then could be used with any Observable implementation or even in any situation, completely unrelated to Observer/Observable, which called for a void method with two Object parameters. 2013: J Paul Gibson TSP: Object Oriented Development CSC7322/DesignII.23
24 Possible Solutions The general opinion is that one should re-use a better/improved Observer. Many such improved Observers exist (the versionby Coad and Mayfield is perhaps the best known) You should be able to write your own! References Gamma, E., Johnson, R. and Vlissides, J., "Design Patterns: Elements of Object-Oriented Architecture", Addison-Wesley, Reading, MA, Coad, P. and Mayfield, M., "Java Design: Building Better Apps and Applets", Yourdon Press, Upper Saddle River, NJ, : J Paul Gibson TSP: Object Oriented Development CSC7322/DesignII.24
25 TO DO Write your own Observable interface Using this interface, make an Observable Dice. Make 2 views: Horizontal and Vertical histograms (you should already have the code for these!) Let these views observe the observable Dice (and update their output accordingly) QUESTION: did your code maximise re-use and re-usability? If not, restructure the code (design) 2013: J Paul Gibson TSP: Object Oriented Development CSC7322/DesignII.25
Fundamental Concepts (In Java)
CSC7322: Object Oriented Development J Paul Gibson, A207 paul.gibson@telecom-sudparis.eu http://www-public.telecom-sudparis.eu/~gibson/teaching/csc7322/ Fundamental Concepts (In Java) /~gibson/teaching/csc7322/l2-fundamentalconcepts.pdf
More informationCSC7322: Object Oriented Development. J Paul Gibson, A207.
CSC7322: Object Oriented Development J Paul Gibson, A207 paul.gibson@telecom-sudparis.eu http://www-public.telecom-sudparis.eu/~gibson/teaching/csc7322/ Design (In Java) /~gibson/teaching/csc7322/l3-design(in
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 informationSYSC Come to the PASS workshop with your mock exam complete. During the workshop you can work with other students to review your work.
It is most beneficial to you to write this mock midterm UNDER EXAM CONDITIONS. This means: Complete the Exam in 3 hour(s). Work on your own. Keep your notes and textbook closed. Attempt every question.
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 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 informationADAPTER. Topics. Presented By: Mallampati Bhava Chaitanya
ADAPTER Presented By: Mallampati Bhava Chaitanya Topics Intent Motivation Applicability Structure Participants & Collaborations Consequences Sample Code Known Uses Related Patterns Intent Convert the interface
More informationDesign Patterns Design patterns advantages:
Design Patterns Designing object-oriented software is hard, and designing reusable object oriented software is even harder. You must find pertinent objects factor them into classes at the right granularity
More informationDesign Patterns. it s about the Observer pattern, the Command pattern, MVC, and some GUI. some more
Lecture: Software Engineering, Winter Semester 2011/2012 some more Design Patterns it s about the Observer pattern, the Command pattern, MVC, and some GUI Design Pattern *...+ describes a problem which
More informationCMSC 331 Second Midterm Exam
1 20/ 2 80/ 331 First Midterm Exam 11 November 2003 3 20/ 4 40/ 5 10/ CMSC 331 Second Midterm Exam 6 15/ 7 15/ Name: Student ID#: 200/ You will have seventy-five (75) minutes to complete this closed book
More informationDesign Patterns: Part 2
Design Patterns: Part 2 ENGI 5895: Software Design Andrew Vardy with code samples from Dr. Rodrigue Byrne and [Martin(2003)] Faculty of Engineering & Applied Science Memorial University of Newfoundland
More informationThe Object Recursion Pattern
SilverMark, Inc. woolf@acm.org OBJECT RECURSION Object Behavioral Intent Distribute processing of a request over a structure by delegating polymorphically. Object Recursion transparently enables a request
More informationDesign Patterns Revisited
CSC 7322 : Object Oriented Development J Paul Gibson, A207 paul.gibson@int-edu.eu http://www-public.it-sudparis.eu/~gibson/teaching/csc7322/ Design Patterns Revisited /~gibson/teaching/csc7322/l13-designpatterns-2.pdf
More 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 informationCSC7203 : Advanced Object Oriented Development J Paul Gibson, D311 MVC Design Pattern
CSC7203 : Advanced Object Oriented Development J Paul Gibson, D311 MVC Design Pattern /~gibson/teaching/csc7203/csc7203-advancedoo-l4-mvc.pdf 1 MVC Design Pattern https://fentyoktorina.files.wordpress.com/2011/05/mvc.jpg
More informationCS112 Lecture: Reuse, Packages, Patterns
CS112 Lecture: Reuse, Packages, Patterns Revised 4/20/05 Objectives: 1. To introduce the idea of re-use 2. To introduce some characteristics that make classes re-usable 3. To introduce Java packages. 4.
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 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 informationB2.52-R3: INTRODUCTION TO OBJECT ORIENTATED PROGRAMMING THROUGH JAVA
B2.52-R3: INTRODUCTION TO OBJECT ORIENTATED PROGRAMMING THROUGH JAVA NOTE: 1. There are TWO PARTS in this Module/Paper. PART ONE contains FOUR questions and PART TWO contains FIVE questions. 2. PART ONE
More informationSoftware Engineering I (02161)
Software Engineering I (02161) Week 10 Assoc. Prof. Hubert Baumeister DTU Compute Technical University of Denmark Spring 2016 Last Time Project Planning Non-agile Agile Refactoring Contents Basic Principles
More informationCSE wi Midterm Exam 2/8/18. Name UW ID #
Name UW ID # There are 11 questions worth a total of 120 points. Please budget your time so you get to all of the questions. Keep your answers brief and to the point. The exam is closed book, closed notes,
More information5.6.1 The Special Variable this
ALTHOUGH THE BASIC IDEAS of object-oriented programming are reasonably simple and clear, they are subtle, and they take time to get used to And unfortunately, beyond the basic ideas there are a lot of
More informationConfiguration Provider: A Pattern for Configuring Threaded Applications
Configuration Provider: A Pattern for Configuring Threaded Applications Klaus Meffert 1 and Ilka Philippow 2 Technical University Ilmenau plop@klaus-meffert.de 1, ilka.philippow@tu-ilmena.de 2 Abstract
More informationAn Expert System for Design Patterns Recognition
IJCSNS International Journal of Computer Science and Network Security, VOL.17 No.1, January 2017 93 An Expert System for Design Patterns Recognition Omar AlSheikSalem 1 and Hazem Qattous 2 1 Department
More informationCSE wi Midterm Exam 2/8/18 Sample Solution
Remember: For all of the questions involving proofs, assertions, invariants, and so forth, you should assume that all numeric quantities are unbounded integers (i.e., overflow can not happen) and that
More informationCOURSE 2 DESIGN PATTERNS
COURSE 2 DESIGN PATTERNS CONTENT Fundamental principles of OOP Encapsulation Inheritance Abstractisation Polymorphism [Exception Handling] Fundamental Patterns Inheritance Delegation Interface Abstract
More informationSoftware Engineering I (02161)
Software Engineering I (02161) Week 11 Assoc. Prof. Hubert Baumeister DTU Compute Technical University of Denmark Spring 2017 Recap I Software Development Processes (cont.) I Project Planning I Design
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 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 informationDesign Patterns. CSC207 Winter 2017
Design Patterns CSC207 Winter 2017 Design Patterns A design pattern is a general description of the solution to a well-established problem using an arrangement of classes and objects. Patterns describe
More 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 informationObject-Oriented Concepts and Design Principles
Object-Oriented Concepts and Design Principles Signature Specifying an object operation or method involves declaring its name, the objects it takes as parameters and its return value. Known as an operation
More 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 informationIdioms for Building Software Frameworks in AspectJ
Idioms for Building Software Frameworks in AspectJ Stefan Hanenberg 1 and Arno Schmidmeier 2 1 Institute for Computer Science University of Essen, 45117 Essen, Germany shanenbe@cs.uni-essen.de 2 AspectSoft,
More informationITI Introduction to Computing II
ITI 1121. Introduction to Computing II Marcel Turcotte School of Electrical Engineering and Computer Science Inheritance Introduction Generalization/specialization Version of January 20, 2014 Abstract
More informationDesign Patterns. CSC207 Fall 2017
Design Patterns CSC207 Fall 2017 Design Patterns A design pattern is a general description of the solution to a well-established problem using an arrangement of classes and objects. Patterns describe the
More information4.1 Introduction Programming preliminaries Constructors Destructors An example... 3
Department of Computer Science Tackling Design Patterns Chapter 4: Factory Method design pattern Copyright c 2016 by Linda Marshall and Vreda Pieterse. All rights reserved. Contents 4.1 Introduction.................................
More 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 informationITI Introduction to Computing II
ITI 1121. Introduction to Computing II Marcel Turcotte School of Electrical Engineering and Computer Science Inheritance Introduction Generalization/specialization Version of January 21, 2013 Abstract
More informationare most specifically concerned with
Observer Behavioral Patterns Behavioral patterns are those patterns that are most specifically concerned with communication between objects Introduction Name Observer Also Known As Dependents, Publish-Subscribe
More informationDesign Patterns. CSC207 Fall 2017
Design Patterns CSC207 Fall 2017 Design Patterns A design pattern is a general description of the solution to a well-established problem using an arrangement of classes and objects. Patterns describe the
More 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 informationIT 313 Advanced Application Development
Page 1 of 10 IT 313 Advanced Application Development Final Exam -- March 13, 2016 Part A. Multiple Choice Questions. Answer all questions. You may supply a reason or show work for partial credit. 5 points
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 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 informationFrameworks and Testing
Frameworks and Testing Stefan Roock Apcon Workplace Solutions & University of Hamburg Vogt-Kölln-Str. 30 22527 Hamburg, Germany +49 40 42883 2302 roock@jwam.de ABSTRACT Testing is one of the main XP practices
More informationWeiss Chapter 1 terminology (parenthesized numbers are page numbers)
Weiss Chapter 1 terminology (parenthesized numbers are page numbers) assignment operators In Java, used to alter the value of a variable. These operators include =, +=, -=, *=, and /=. (9) autoincrement
More informationInheritance. Inheritance Reserved word protected Reserved word super Overriding methods Class Hierarchies Reading for this lecture: L&L
Inheritance Inheritance Reserved word protected Reserved word super Overriding methods Class Hierarchies Reading for this lecture: L&L 9.1 9.4 1 Inheritance Inheritance allows a software developer to derive
More informationCS/B.TECH/CSE(New)/SEM-5/CS-504D/ OBJECT ORIENTED PROGRAMMING. Time Allotted : 3 Hours Full Marks : 70 GROUP A. (Multiple Choice Type Question)
CS/B.TECH/CSE(New)/SEM-5/CS-504D/2013-14 2013 OBJECT ORIENTED PROGRAMMING Time Allotted : 3 Hours Full Marks : 70 The figures in the margin indicate full marks. Candidates are required to give their answers
More informationPatterns for polymorphic operations
Patterns for polymorphic operations Three small object structural patterns for dealing with polymorphism Alexander A. Horoshilov hor@epsylontech.com Abstract Polymorphism is one of the main elements of
More 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 informationAP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS
AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS PAUL L. BAILEY Abstract. This documents amalgamates various descriptions found on the internet, mostly from Oracle or Wikipedia. Very little of this
More informationDesigning Robust Classes
Designing Robust Classes Learning Goals You must be able to:! specify a robust data abstraction! implement a robust class! design robust software! use Java exceptions Specifications and Implementations
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 information25.1 Introduction Façade Design Pattern Identification Problem Structure Participants...
Department of Computer Science Tackling Design Patterns Chapter 25: Façade Design Pattern Copyright c 2016 by Linda Marshall and Vreda Pieterse. All rights reserved. Contents 25.1 Introduction.................................
More informationCSC System Development with Java. Exception Handling. Department of Statistics and Computer Science. Budditha Hettige
CSC 308 2.0 System Development with Java Exception Handling Department of Statistics and Computer Science 1 2 Errors Errors can be categorized as several ways; Syntax Errors Logical Errors Runtime Errors
More informationModel-View-Controller Architecture
--Controller Architecture --Controller Architecture Controller --Controller (MVC) is an architectural pattern, a standard design in the field of software architecture. Heavily used by Apple in writing
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 information3. Convert 2E from hexadecimal to decimal. 4. Convert from binary to hexadecimal
APCS A Midterm Review You will have a copy of the one page Java Quick Reference sheet. This is the same reference that will be available to you when you take the AP Computer Science exam. 1. n bits can
More informationLecture 3. COMP1006/1406 (the Java course) Summer M. Jason Hinek Carleton University
Lecture 3 COMP1006/1406 (the Java course) Summer 2014 M. Jason Hinek Carleton University today s agenda assignments 1 (graded) & 2 3 (available now) & 4 (tomorrow) a quick look back primitive data types
More informationMaking New instances of Classes
Making New instances of Classes NOTE: revised from previous version of Lecture04 New Operator Classes are user defined datatypes in OOP languages How do we make instances of these new datatypes? Using
More informationEINDHOVEN UNIVERSITY OF TECHNOLOGY
EINDHOVEN UNIVERSITY OF TECHNOLOGY Department of Mathematics & Computer Science Exam Programming Methods, 2IP15, Wednesday 17 April 2013, 09:00 12:00 TU/e THIS IS THE EXAMINER S COPY WITH (POSSIBLY INCOMPLETE)
More informationWhat are the characteristics of Object Oriented programming language?
What are the various elements of OOP? Following are the various elements of OOP:- Class:- A class is a collection of data and the various operations that can be performed on that data. Object- This is
More informationThe following topics will be covered in this course (not necessarily in this order).
The following topics will be covered in this course (not necessarily in this order). Introduction The course focuses on systematic design of larger object-oriented programs. We will introduce the appropriate
More informationPolymorphism. return a.doublevalue() + b.doublevalue();
Outline Class hierarchy and inheritance Method overriding or overloading, polymorphism Abstract classes Casting and instanceof/getclass Class Object Exception class hierarchy Some Reminders Interfaces
More informationGUJARAT TECHNOLOGICAL UNIVERSITY
GUJARAT TECHNOLOGICAL UNIVERSITY MASTER OF COMPUTER APPLICATIONS (COURSE CODE-6) Subject: Java Programming Subject Code: 2630002 Year II (Semester III) (W.E.F. JULY 2013) Objectives: To develop proficiency
More informationpublic static boolean isoutside(int min, int max, int value)
See the 2 APIs attached at the end of this worksheet. 1. Methods: Javadoc Complete the Javadoc comments for the following two methods from the API: (a) / @param @param @param @return @pre. / public static
More informationTwin A Design Pattern for Modeling Multiple Inheritance
Twin A Design Pattern for Modeling Multiple Inheritance Hanspeter Mössenböck University of Linz, Institute of Practical Computer Science, A-4040 Linz moessenboeck@ssw.uni-linz.ac.at Abstract. We introduce
More informationJava Application Development
A Absolute Size and Position - Specifying... 10:18 Abstract Class... 5:15 Accessor Methods...4:3-4:4 Adding Borders Around Components... 10:7 Adding Components to Containers... 10:6 Adding a Non-Editable
More informationSummary of the course lectures
Summary of the course lectures 1 Components and Interfaces Components: Compile-time: Packages, Classes, Methods, Run-time: Objects, Invocations, Interfaces: What the client needs to know: Syntactic and
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 informationOutline. Computer Science 331. Information Hiding. What This Lecture is About. Data Structures, Abstract Data Types, and Their Implementations
Outline Computer Science 331 Data Structures, Abstract Data Types, and Their Implementations Mike Jacobson 1 Overview 2 ADTs as Interfaces Department of Computer Science University of Calgary Lecture #8
More informationObject Oriented Design. Object-Oriented Design. Inheritance & Polymorphism. Class Hierarchy. Goals Robustness Adaptability Flexible code reuse
Object-Oriented Design Object Oriented Design Goals Robustness Adaptability Flexible code reuse Principles Abstraction Encapsulation Modularity March 2005 Object Oriented Design 1 March 2005 Object Oriented
More informationDesign Patterns Revisited
CSC 7322 : Object Oriented Development J Paul Gibson, A207 /~gibson/teaching/csc7322/ Design Patterns Revisited /~gibson/teaching/csc7322/l11-designpatterns-2.pdf 2013: J Paul Gibson TSP: Software Engineering
More informationJava Fundamentals p. 1 The Origins of Java p. 2 How Java Relates to C and C++ p. 3 How Java Relates to C# p. 4 Java's Contribution to the Internet p.
Preface p. xix Java Fundamentals p. 1 The Origins of Java p. 2 How Java Relates to C and C++ p. 3 How Java Relates to C# p. 4 Java's Contribution to the Internet p. 5 Java Applets and Applications p. 5
More informationSoftware Engineering - I An Introduction to Software Construction Techniques for Industrial Strength Software
Software Engineering - I An Introduction to Software Construction Techniques for Industrial Strength Software Chapter 9 Introduction to Design Patterns Copy Rights Virtual University of Pakistan 1 Design
More informationSSJ User s Guide. Package stat Tools for Collecting Statistics. Version: December 21, 2006
SSJ User s Guide Package stat Tools for Collecting Statistics Version: December 21, 2006 CONTENTS 1 Contents Overview........................................ 2 StatProbe........................................
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 informationProduced by. Design Patterns. MSc in Computer Science. Eamonn de Leastar
Design Patterns MSc in Computer Science Produced by Eamonn de Leastar (edeleastar@wit.ie) Department of Computing, Maths & Physics Waterford Institute of Technology http://www.wit.ie http://elearning.wit.ie
More 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 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 informationObject-Oriented Design. March 2005 Object Oriented Design 1
Object-Oriented Design March 2005 Object Oriented Design 1 Object Oriented Design Goals Robustness Adaptability Flexible code reuse Principles Abstraction Encapsulation Modularity March 2005 Object Oriented
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 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 informationCSCI 200 Lab 4 Evaluating infix arithmetic expressions
CSCI 200 Lab 4 Evaluating infix arithmetic expressions Please work with your current pair partner on this lab. There will be new pairs for the next lab. Preliminaries In this lab you will use stacks and
More informationAlternator. An Object Behavioral Design Pattern. John Liebenau
Alternator An Design Pattern John Liebenau lieb@itginc.com Copyright 1999, John Liebenau. Permission is granted to copy for the PLoP 1999 conference. All other rights reserved. July 23, 1999 Page 1 1.
More informationAdapter Pattern Structural
Adapter Pattern Structural Intent» Convert the interface of a class into a different interface that a client expects.» Lets classes work together that otherwise could not Adapter-1 Class Adapter Motivation
More informationName: CS 159 Practice Final Fall 2015
Name: CS 159 Practice Final Fall 2015 CS 159, Fall 2015 Final Exam Section 02 Page 2 of 16 1. Choose the best answer for each of the following multiple choice questions. (a) (2 points) What will happen
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 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 information6 The MVC model. Main concepts to be covered. Pattern structure. Using design patterns. Design pattern: Observer. Observers
Main concepts to be covered 6 The MVC model Design patterns The design pattern The architecture Using design patterns Inter-class relationships are important, and can be complex. Some relationship recur
More informationCONTENTS. PART 1 Structured Programming 1. 1 Getting started 3. 2 Basic programming elements 17
List of Programs xxv List of Figures xxix List of Tables xxxiii Preface to second version xxxv PART 1 Structured Programming 1 1 Getting started 3 1.1 Programming 3 1.2 Editing source code 5 Source code
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 informationPatterns for Decoupling
Patterns for Decoupling Ingolf H. Krueger Department of Computer Science & Engineering University of California, San Diego La Jolla, CA 92093-0114, USA California Institute for Telecommunications and Information
More informationpublic static void negate2(list<integer> t)
See the 2 APIs attached at the end of this worksheet. 1. Methods: Javadoc Complete the Javadoc comments for the following two methods from the API: (a) / @param @param @param @return @pre. / public static
More informationLecture 9: UI Software Architecture. Fall UI Design and Implementation 1
Lecture 9: UI Software Architecture Fall 2003 6.893 UI Design and Implementation 1 UI Hall of Fame or Shame? Source: Interface Hall of Shame Fall 2003 6.893 UI Design and Implementation 2 Today s hall
More informationName: CS 159 Practice Final Fall 2015
Name: CS 159 Practice Final Fall 2015 CS 159, Fall 2015 Final Exam Section 02 Page 2 of 17 1. Choose the best answer for each of the following multiple choice questions. (a) (2 points) What will happen
More informationADVANCED SOFTWARE DESIGN LECTURE 4 SOFTWARE ARCHITECTURE
ADVANCED SOFTWARE DESIGN LECTURE 4 SOFTWARE ARCHITECTURE Dave Clarke 1 THIS LECTURE At the end of this lecture you will know notations for expressing software architecture the design principles of cohesion
More informationCS 61B Discussion 5: Inheritance II Fall 2014
CS 61B Discussion 5: Inheritance II Fall 2014 1 WeirdList Below is a partial solution to the WeirdList problem from homework 3 showing only the most important lines. Part A. Complete the implementation
More informationCocoa Design Patterns. Erik M. Buck October 17, 2009
Cocoa Design Patterns Erik M. Buck October 17, 2009 Topics n What is a design pattern? n Why Focus on design patterns? n What is the Model View Controller design pattern? n Using MVC n When wouldn t you
More information