Ready for the Real World. Kenneth M. Anderson University of Colorado, Boulder CSCI 4448/6448 Lecture 8 09/18/2007

Similar documents
Ready for the Real World. Kenneth M. Anderson University of Colorado, Boulder CSCI 4448/5448 Lecture 8 09/17/2009

PRINCIPLES OF SOFTWARE BIM209DESIGN AND DEVELOPMENT 03. REQUIREMENTS CHANGE. I Love You, You re Perfect... Now Change!

UML & OO FUNDAMENTALS CSCI 4448/5448: OBJECT-ORIENTED ANALYSIS & DESIGN LECTURE 3 08/30/2011

Good-Enough Design. Kenneth M. Anderson University of Colorado, Boulder CSCI 5828 Lecture 11 02/17/2009

UML & OO Fundamentals. CSCI 4448/5448: Object-Oriented Analysis & Design Lecture 3 09/04/2012

Originality is Overrated: OO Design Principles

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

Good-Enough Design & Version Control. Kenneth M. Anderson University of Colorado, Boulder CSCI 5828 Lecture 11 02/16/2010

08. DESIGN PRINCIPLES. Originality is Overrated PRINCIPLES OF SOFTWARE BIM209DESIGN AND DEVELOPMENT

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

IMPORTANT WORDS AND WHAT THEY MEAN

Dealing with Bugs. Kenneth M. Anderson University of Colorado, Boulder CSCI 5828 Lecture 27 04/21/2009

Credit where Credit is Due. Lecture 4: Fundamentals of Object Technology. Goals for this Lecture. Real-World Objects

Object Fundamentals Part Three. Kenneth M. Anderson University of Colorado, Boulder CSCI 4448/6448 Lecture 4 09/06/2007

ER modeling. Lecture 4

Object Fundamentals Part Two. Kenneth M. Anderson University of Colorado, Boulder CSCI 4448/5448 Lecture 3 09/01/2009

Software Testing Prof. Meenakshi D Souza Department of Computer Science and Engineering International Institute of Information Technology, Bangalore

Introduction to User Stories. CSCI 5828: Foundations of Software Engineering Lecture 05 09/09/2014

Algebra (Linear Expressions & Equations)

English as a Second Language Podcast ESL Podcast 314 Buying a Digital Audio (MP3) Player

Originality is Overrated: OO Design Principles & Iterating And Testing

Spam. Time: five years from now Place: England

How To Sync Iphone To New Itunes Without >>>CLICK HERE<<<

course 3 Levels of Database Design CSCI 403 Database Management Mines Courses ERD Attributes Entities title 9/26/2018

Legal Notice: Copyright 2012 and 2013 Hitman Advertising, all rights reserved. You are responsible for your own advertising in your business.

The name of our class will be Yo. Type that in where it says Class Name. Don t hit the OK button yet.

Part II Composition of Functions

Expanding Our Horizons. CSCI 4448/5448: Object-Oriented Analysis & Design Lecture 9 09/25/2011

CS112 Lecture: Defining Classes. 1. To describe the process of defining an instantiable class

itunes What Is It? What Does it Do?

UML data models from an ORM perspective: Part 4

Lecture 8 Requirements Engineering

Working with Objects. Overview. This chapter covers. ! Overview! Properties and Fields! Initialization! Constructors! Assignment

More OO Fundamentals. CSCI 4448/5448: Object-Oriented Analysis & Design Lecture 4 09/11/2012

Basic Structural Modeling. Copyright Joey Paquet,

1. Write two major differences between Object-oriented programming and procedural programming?

Digital Workflow 10 Tech Rules to Guide You

Learning from Bad Examples. CSCI 5828: Foundations of Software Engineering Lecture 25 11/18/2014

CS112 Lecture: Defining Instantiable Classes

10 Strategies for Effective Marketing Campaigns

5 R1 The one green in the same place so either of these could be green.

Input, output, and sequence

Introduction to UML What is UML? Motivations for UML Types of UML diagrams UML syntax Descriptions of the various diagram types Rational Rose (IBM.. M

Object- Oriented Design with UML and Java Part I: Fundamentals

Common iphone problems, tips and tricks

1.7 Limit of a Function

Project Collaboration

These are notes for the third lecture; if statements and loops.

As a programmer, you know how easy it can be to get lost in the details

MORE OO FUNDAMENTALS CSCI 4448/5448: OBJECT-ORIENTED ANALYSIS & DESIGN LECTURE 4 09/01/2011

Hello! ios Development

To Update and Maintain Your Team Website

2.4 Choose method names carefully

2 Sets. 2.1 Notation. last edited January 26, 2016

CSCI0170. Today s topics. Predicates Natural Number recursion Recursion Diagrams List recursion A first glance at the design recipe

Getting the. Message. Across. JANUARY 2017 // dentaltown.com

user.book Page 45 Friday, April 8, :05 AM Part 2 BASIC STRUCTURAL MODELING

CMPSCI 187: Programming With Data Structures. Lecture 6: The StringLog ADT David Mix Barrington 17 September 2012

CMSC201 Computer Science I for Majors

Images help us relate to content, help us become involved. They help us to see ourselves in the science, rather than standing on the outskirts.

Object-Oriented Software Engineering Practical Software Development using UML and Java

Become a Champion Data Modeler with SQL Developer Data Modeler 3.0

Plus 10: Descending the Design Funnel THE 10 PLUS 10 METHOD. developing 10 different ideas and refinements of selected ideas

Trombone players produce different pitches partly by varying the length of a tube.

Design First ITS Instructor Tool

UNIT-4 Behavioral Diagrams

15 Minute Traffic Formula. Contents HOW TO GET MORE TRAFFIC IN 15 MINUTES WITH SEO... 3

Object-Oriented Analysis and Design Prof. Partha Pratim Das Department of Computer Science and Engineering Indian Institute of Technology-Kharagpur

SOFTWARE ENGINEERING Prof.N.L.Sarda Computer Science & Engineering IIT Bombay. Lecture #10 Process Modelling DFD, Function Decomp (Part 2)

Lecture 5. Lecture 5: The E/R Model

IT S ALL ABOUT THE OPEN RATE. Best Practices, Tactics and Tips for Writing Better Subject Lines.

Programming in C ++ Prof. Partha Pratim Das Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur

PRINCIPLES OF SOFTWARE BIM209DESIGN AND DEVELOPMENT 10. PUTTING IT ALL TOGETHER. Are we there yet?

ios 9.3 ipads & iphones What you need to know! Jere Minich, APCUG Advisor, Region 5 Program Chair, Lake-Sumter Computer Society

(Refer Slide Time: 1:43)

For this chapter, switch languages in DrRacket to Advanced Student Language.

The Basics of Variable Data. Tips for Using Variable Data Within your Direct Marketing Campaigns

Part 2: The Material PART 2

File Associations - Changing Defaults. Created by Sherry Surdam

Let life inspire you. with ReSound Unite wireless accessories. Learn more about ReSound Unite wireless accessories.

Implementing Rules. Java rules ok

Software Design and Analysis for Engineers

EPISODE 23: HOW TO GET STARTED WITH MAILCHIMP

I Travel on mobile / FR

3 Nonlocal Exit. Quiz Program Revisited

Apple iphone Battery Life Tweak

Test-Driven Development

ipod classic User Guide

Lecture 9 Requirements Engineering II

News English.com Ready-to-use ESL / EFL Lessons

Refactoring, Part 2. Kenneth M. Anderson University of Colorado, Boulder CSCI 4448/5448 Lecture 27 12/01/09. University of Colorado, 2009

balancer high-fidelity prototype dian hartono, grace jang, chris rovillos, catriona scott, brian yin

CSCI 1100L: Topics in Computing Lab Lab 11: Programming with Scratch

Class diagrams and architectural design

Have the students look at the editor on their computers. Refer to overhead projector as necessary.

Eanes ios5 Upgrade Guide

I Travel on mobile / UK

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

Programming in C++ Prof. Partha Pratim Das Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur

The Entity-Relationship Model (ER Model) - Part 2

Transcription:

Ready for the Real World Kenneth M. Anderson University of Colorado, Boulder CSCI 4448/6448 Lecture 8 09/18/2007

Lecture Goals Review material from Chapter 4 of the OO A&D textbook Taking Your Software into the Real World Alternative Designs / Design Trade-Offs Use Case Analysis / More about Class Diagrams Discuss the Chapter 4 Example: Todd & Gina s Dog Door, Take 3 Emphasize the OO concepts and techniques encountered in Chapter 4 2

Real World Context A key problem in software development is gaining an understanding of the context in which your software must operate Chapter 4 starts out by identifying a problem with our bark recognizer software from the end of Chapter 3: It opens for ANY bark even if the bark belongs to some other dog! In the perfect world, everyone uses your system just like you expect As the book says Everyone is relaxed and there are no multi-dog neighborhoods here! In the real world, (unexpected) stuff happens and things go wrong Analysis is the tool that can help you understand your software s real-world context, identify potential problems, and help you avoid them 3

The Role of Use Cases A well written use case can aid us in our goal of identifying real-world problems during the analysis phase They are your means of communicating with your customers, your managers, and other developers about how your system will work in the real world A customer may look at your scenarios and say these are not very realistic Be open to comments like this, because you can then learn how to change your use cases to take into account the problems that will be encountered in the real world Once your use cases are updated, you can use them to glean the new requirements your system has to meet 4

Initial Changes Make use case more generic We ve been a bit folksy up to now, referring to Todd and Gina and Fido in our use case We ll switch to using phrases like owner and dog Except that in Boulder, we have to say guardian not owner We ll update the use case to make sure that we specify that the bark recognizer opens the door ONLY for the owner s dog We were playing fast and loose with requirements last time looking at what we needed to do to introduce BarkRecognizer to our design, without thinking long and hard about what it really needed to do 5

New Use Case What the Door Does Main Path 1. The owner s dog barks to be let out. 2. The bark recognizer hears a bark. 3. The bark recognizer detects the owner s dog and opens the door. 4. The dog door opens. 5. The owner s dog goes outside. 6. The owner s dog does his business. 6.1 The door shuts automatically 6.2 Fido barks to be let back inside. 6.3 The bark recognizer hears a bark (again). 6.4 The bark recognizer detects the owner s dog and opens the door 6.5 The dog door opens (again). 7. Fido goes back inside. Alternate Paths 2.1 The owner hears her dog barking. 3.1 The owner presses the button on the remote control. 6.3.1 The owner hears her dog barking (again). 6.4.1 The owner presses the button on the remote control. 6

Discussion Note: I did things slightly differently from the book I changed step 3 to say The bark recognizer detects the owner s dog and opens the door The book said If it s the owner s dog barking, the bark recognizer sends a request to the door to open I didn t like the use of if in this action step, instead I just decided that the bark we hear is always the owner s dog. I can add an additional path to this use case in which I can say something like: The bark recognizer detects an unknown dog. Use case terminates. Or I can create a separate use case that documents this behavior Note: my version of step 3 can be further improved by splitting it into two steps: one that does the detection and one that asks for the door to open 7

New Use Case If the bark recognizer is going to determine if a bark belongs to the owner s dog, we need to store a representation of that dog s bark Storing a dog bark 1. The owner s dog barks into the door. 2. The door stores the owner s dog s bark. This may seem like its not enough : Pros: simple, primary actor should be dog in this use case Cons: It feels a bit weird not to have a step that says something like The owner issues a command to the door to prepare it to store the dog s bark But since that step sounds awkward, make it a precondition 8

The Competition The book now holds a design competition between two programmers Randy: simple is best right? Bark sounds are just strings I ll store the owner s dog s bark in the dog door and then just do a string comparison in bark recognizer Sam: object lover extraordinaire A bark is an important concept in our application domain. Lets make it a class and have it take care of bark comparison 9

Discussion Randy s approach Agile approach to software development What is the simplest thing I can do today to meet my requirements? Avoids speculative complexity Fast: doesn t take long to modify the DogDoor class and update the BarkRecognizer to do the appropriate string comparison Sam s approach Makes use of good OO design principles Encapsulation and Delegation A bark is something we need to track it should be a class Barks are strings now; But what if they turn into.wav files? Use delegation to hide those details from the rest of the system 10

Original Class Diagram BarkRecognizer recognize(bark: string) door DogDoor open: boolean open() close() isopen(): boolean door Remote pressbutton() DogDoorSimulator 11

:DogDoorSimulator «create» :DogDoor «create» «create» println("fido starts barking.") Behavior of Original System :BarkRecognizer :Remote :System.out recognize("woof") «create» schedule() open() println("barkrecognizer: Heard a 'Woof'.") println("the dog door opens.") :Timer sleep(5000) println("fido has gone outside...") println("fido's all done...") sleep(10000) close() println("the dog door closes.") println("...but he's stuck outside!") println("fido starts barking.") recognize("woof") Insert another copy of the interaction shown above here println("fido's back inside...") 12

Introduction to Sequence Diagrams Objects are shown across the top of the diagram Objects at the top of the diagram existed when the scenario begins All other objects are created during the execution of the scenario Each object has a vertical dashed line known as its lifeline When an object is active, the lifeline has a rectangle placed above its lifeline If an object dies during the scenario, its lifeline terminates with an X Messages between objects are shown with lines pointing at the object receiving the message The line is labeled with the method being called and (optionally) its parameters All UML diagrams can be annotated with notes Sequence diagrams can be useful, but they are also labor intensive (!) 13

Randy s Class Diagram BarkRecognizer recognize(bark: string) door DogDoor open: boolean allowedbark: String open() close() isopen(): boolean getallowedbark(): String setallowedbark(bark: String) door Remote pressbutton() DogDoorSimulator BarkRecognizer s recognize() method has been updated to call getallowedbark() and check to see if it matches the bark passed to it 14

Sam s Class Diagram Bark sound: String getsound() : String equals(object bark): boolean recognize() delegates comparison to the Bark equals() method BarkRecognizer recognize(bark: Bark) door allowedbark DogDoor open: boolean open() close() isopen(): boolean getallowedbark(): Bark setallowedbark(bark: Bark) door Remote pressbutton() DogDoorSimulator 15

The Power of Delegation Sam s application is shielded from the details of how a bark is implemented By using delegation to do the comparison of bark objects, his BarkRecognizer doesn t have to know that internally a bark is represented as a String If we change the way a bark is represented, BarkRecognizer will be unaffected Contrast with an alternative approach of BarkRecognizer calling the getsound() method of its two Bark objects and then doing a comparison itself; BarkRecognizer would then be tied to the implementation of the Bark class Delegation shields your objects from implementation changes to other objects in your software The coupling between Bark and BarkRecognizer is looser having used delegation; there is still some coupling between them, but its not tight 16

The Results Sam s and Randy s solutions both work but both of them lost the competition! They lost to a summer intern (and junior programmer), Maria Why? She did a deeper analysis of the problem domain and identified a problem that both Sam and Randy ignored The same dog can have different types of barks! when its excited, sleepy, hungry, angry, scared, etc. Sam s and Randy s solutions would both fail in the real world Maria succeeded because she applied textual analysis to the use case She realized that it was the dog that was the focus, not the bark 17

Textual Analysis Pay attention to the nouns in your use case They may indicate a potential candidate for a class in your system Some things don t need to be tracked For example, we don t need a class for Dog in this system They also provide hints on what your design should focus on Pay attention to the verbs in your use case as well They may indicate potential candidates for methods in your system They will also provide hints as to where a method should live i.e. what class should be assigned the responsibility of handling the service provided by the method 18

Soft Science? The book discusses the potential problems with textual analysis Wouldn t a slightly different wording of the use case lead to different results? Yep But, as they point out, only one or two wordings will accurately capture the real-world context that your system will find itself in If you get your analysis wrong, you ll end up focused on the wrong thing, and even if your design is good, your system will fail Also, everyone does it : this technique shows up in all OO A&D methods A good use case clearly and accurately explains what a system does, in language that s easily understood with real world context captured With a good use case, complete textual analysis is a quick and easy way to identify the potential classes and methods of your system 19

Maria s Class Diagram Bark sound: String getsound() : String equals(object bark): boolean allowedbark * BarkRecognizer recognize(bark: Bark) door DogDoor open: boolean open() close() isopen(): boolean getallowedbarks(): Bark [*] addallowedbark(bark: Bark) door Remote pressbutton() DogDoorSimulator 20

New Notation In Maria s class diagrams in the book, you encountered a new notation For Attributes allowedbarks: Bark [*] For Methods getallowedbarks(): Bark [*] (actually, its just a new type notation) It means that the type of allowedbarks and the return type of getallowedbarks() is a collection of zero or more Bark objects You can indicate a specific multiplicity like this allowedbarks: Bark [2..6] or allowedbarks: Bark [20] 21

Demonstration Lets take a look at the final version of the software 22

Class Diagrams are Incomplete Class diagrams are useful but they do not provide a complete picture They provide limited type information Types are optional, and when a type specifies a multiplicity it does not indicate what collection class should be used They don t tell you how to code a method You ll need a use case or sequence diagram for that They almost never talk about constructors They do not provide information on how associations are instantiated They don t provide explicit information on the purpose of a class That info comes from its associated requirements and use cases They are horrible at specifying constraints that span multiple classes 23

wife 0..1 Bank accountnumber * 0..1 customer Person ismarried: Boolean isunemployed: Boolean birthdate: Date age: Integer firstname: String lastname: String gender: Gender income(date): Integer Multi-Class Constraints manager 1 employee * Is the Manager of a Company also an Employee? Can the Wife and Husband of a Marriage be the same Person? Same Gender? Can two people with the same job title at the same company have different salaries? * managedcompanies * employer Company name: String numberofemployees: Integer stockprice(): Double husband Marriage startdate: Date enddate: Date 0..1 Job title: String startdate: Date enddate: Date salary: Integer Note: new notations: Role Names Association Classes 24

OCL to the Rescue! To handle the problem of constraints that span multiple classes, a designer can make use of the object constraint language OCL version 2.0 specification located here: <http://www.omg.org/docs/ptc/05-06-06.pdf> Essentially defines a first-order predicate logic that has its domain in UML models; you can construct statements like All Persons employed by Company X with Job title Y have salary Z For all Persons X, manager(x, Company) and employee(x, Company) etc. You can then annotate UML models with OCL constraints using notes Example of note shown on slide 12 Knowledge of OCL is NOT required for this class 25

Wrapping Up Systems fail if their developers failed to take into account the problems that they will encounter in the real world Its tough to model the real world accurately but it can be done if you are willing to expend the effort to create good use cases A good use case precisely lays out what a system does, but does not indicate how the system accomplishes that task Textual analysis can provide you with information on the candidate classes and methods of your system they also indicate where to focus when creating the design of your system get the use case wrong, and you ll focus on the wrong thing 26

Ken s Corner Lets Practice Modeling Jewel Quest II Lets take a look at the game and then identify classes and methods Be writing down potential classes during the demo itunes (if we have time) Huge number of responsibilities It used to be just a music player; Now it: plays music, podcasts, tv shows, movies, stores apps/games synchronizes devices (ipods, Apple TV, iphones) itunes store (purchases and rentals) App store for iphone 27

Coming Up Next Lecture 9: Nothing Stays the Same Read Chapter 5 (part 1 and interlude) of the OO A&D book Lecture 10: Flexible Software Read Chapter 5 (part 2) of the OO A&D book 28