Unformatted text preview:

Ready for the Real WorldKenneth M. AndersonUniversity of Colorado, BoulderCSCI 4448/6448 — Lecture 8 — 09/18/2007Thursday, September 18, 2008Lecture 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 42Thursday, September 18, 2008Real 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 them3Thursday, September 18, 2008The 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 meet4Thursday, September 18, 2008Initial 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 do5Thursday, September 18, 2008New Use Case6What the Door DoesMain Path1. 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 automatically6.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 door6.5 The dog door opens (again).7. Fido goes back inside.Alternate Paths2.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.Thursday, September 18, 2008Discussion• 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 open7Thursday, September 18, 2008New 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• 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 precondition8Storing a dog bark1. The owner’s dog barks “into” the door.2. The door stores the owner’s dog’s bark.Thursday, September 18, 2008The 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”9Thursday, September 18, 2008Discussion•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 system10Thursday, September 18, 2008Original Class Diagramrecognize(bark: string)BarkRecognizerpressButton()Remoteopen()close()isOpen(): booleanopen: booleanDogDoordoordoorDogDoorSimulator11Thursday, September 18, 200812:DogDoorSimulator:DogDoor:BarkRecognizer:Remote:System.out«create»«create»«create»println("Fido starts barking.")recognize("Woof")println("BarkRecognizer: Heard a 'Woof'.")open()println("The dog door opens.")«create»:Timerschedule()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


View Full Document

CU-Boulder CSCI 6448 - Ready for the Real World

Documents in this Course
Struts

Struts

12 pages

Adapter

Adapter

23 pages

Prototype

Prototype

16 pages

Weka

Weka

15 pages

qooxdoo

qooxdoo

16 pages

Django

Django

12 pages

Overview

Overview

22 pages

XNA

XNA

5 pages

Load more
Download Ready for the Real World
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Ready for the Real World and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Ready for the Real World 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?