1 / 23

Object Oriented Analysis and Design

Object Oriented Analysis and Design. Chapter 4: Analysis. Welcome!. 10 (+) week book study Tom Perkins tomperki@gmail.com Books available at Nerdbooks.com http://69.41.237.216/STUDYGROUPSIG/OOAD. Welcome!. Chapter 4: Analysis tomperki@gmail.com. Objectives. Review Homework

nairi
Télécharger la présentation

Object Oriented Analysis and Design

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Object Oriented Analysis and Design Chapter 4: Analysis

  2. Welcome! • 10 (+) week book study • Tom Perkins • tomperki@gmail.com • Books available at Nerdbooks.com • http://69.41.237.216/STUDYGROUPSIG/OOAD

  3. Welcome! • Chapter 4: Analysis • tomperki@gmail.com

  4. Objectives • Review Homework • Review Doug’s Dog Door app • Review existing Class Diagrams • Introduce new problem design opportunity • Modified Use Case • 2 ways to handle (Randy and Sam) • Delegation • Textual Analysis • Associations • In-class exercise • Homework assignment • Summary

  5. Homework Review • Handouts • Use Cases: • Single goal,Single Start, Single End • Happy Path, Alternative Paths • Used to communicate with customers • Part of Agile design/development process • Problem: Write a Use Case describing how an ATM handles a cash withdrawal transaction • Walkthru Use Case

  6. Todd Gina Fido Your new programming job: Doug’s Dog Doors (High tech, automated dog doors) Your first Customers What they want: An automated, remote-controlled Dog Door barks !!! want to push button to open door No Problem !!!

  7. Todd and Gina’s Dog Door, Version 2.0 (Review) Dog Door Use Case 1. Fido barks to be let out. 2. Todd or Gina hears Fido barking. 3. Todd or Gina presses the button on the remote control. 4. The dog door opens. 5. Fido goes outside. 6. Fido does his business.. 6.1 The door shuts automatically. 6.2 Fido barks to be let in. 6.3 Todd or Gina hears Fido barking (again). 6.4 Todd or Gina presses button on remote control. 6.5 The dog door opens (again). 7. Fido goes back inside. 8. The door shuts automatically.

  8. Doug and Gina’s Idea Bark Recognizer Attachment Fido It (the dog door) is working great, but what if … Dog Door Opens! barks (Woof-Woof )!!!

  9. A Revised Use Case Alternate paths: 2.1 Todd or Gina hears Fido 3.1 Todd or Gina presses remote control 6.1 Dog door shuts automatically 6.2 Fido barks 6.3 Bark recognizer hears bark 6.3.1 Todd or Gina hears 6.4. Bark recognizer requests 6.4.1 Todd or Gina presses remote 6.5 Dog door opens Main Path 1. Fido barks to be let out 2. Bark Recognizer hears 3. Bark Recognizer send open request 4. Dog door opens 5. Fido goes outside 6. Fido does his business. 7. Fido goes back inside. 8. Dog door shuts automatically

  10. Our Classes dogDoor remote open:bool door:dogDoor Open() Close() isOpen():bool pressButton() recognizer door:dogDoor recognize(String)

  11. A new problem … Bruce’s owner: “Don’t get me wrong, I like the dog door. The problem is that it opens when other dogs in the neighborhood bark. Can you do something to fix this?” Bruce

  12. A modified Use Case 2. The bark recognizer “hears” a bark. 3. If it’s the owner’s dog barking, the bark recognizer sends a request to the door to open. … 6.3 The bark recognizer “hears” a bark. 6.4 If it’s the owner’s dog barking, the bark recognizer sends a request to the door to open. …

  13. Randy’s solution public class DogDoor { private boolean open; private string allowedBark; public DogDoor() { open = false; } public void setAllowedBark(String bark) { this.allowedBark = bark; } public string getAllowedBark() { return allowedBark; } // other code } dogDoor open:bool allowedBark:String Open() Close() isOpen():bool setAllowedBark(string) getAllowedBark(string)

  14. Sam (Mr Object Guy)’s Solution public class Bark { private string sound; public Bark(string sound){ this.sound = sound; } public string getSound() { return sound; } public boolean equals(Object bark){ if (bark instanceof Bark) { Bark otherBark = (Bark) bark; if (this.sound.equalsIgnoreCase(bark.getSound() { return true; } } return false; } Bark sound:string getSound:string equals(Object bark): boolean

  15. Comparing “recognize()” methods String comparison Randy public class BarkRecognizer(){ public void recognize(string bark) . . . if (door.getAllowedBark().equals(bark){ door.open();} else {print(“no,no,no!”) Delegated comparison-Sam public class BarkRecognizer(){ public void recognize(Bark bark) print(“Heard “ + bark.getSound()) if (door.getAllowedBark().equals(bark){ door.open();} else {print(“no,no,no!”)

  16. Take-away • Loosely-coupled classes: It’s a good thing! • Suppose instead of a string, we have a .WAV file to record Bruce’s voice. • Randy must change both the DogDoor and Recognizer classes; Sam has to change only the Recognizer class. • Delegation shields your objects from implementation changes to other objects in your application.

  17. … but Maria wins the laptop computer • She allowed many variations of Bruce’s bark • allowedBarks:Bark[*] • Multiplicity of an attribute (how many times it occurs)

  18. What’s Maria’s approach? • Textual analysis • Examine the Use Case for Nouns (possible classes) and Verbs (possible methods)

  19. Our Use Case Find the nouns and verbs Alternate paths: 2.1 Todd or Gina hears Fido 3.1 Todd or Gina presses remote control 6.1 Dog door shuts automatically 6.2 Fido barks 6.3 Bark recognizer hears bark 6.3.1 Todd or Gina hears 6.4. If it’s the owner’s dog barking, the bark recognizer sends a request to the door to open. 6.4.1 Todd or Gina presses remote 6.5 Dog door opens Main Path 1. Fido barks to be let out 2. Bark Recognizer hears 3. If it’s the owner’s dog barking, the bark recognizer sends a request to the door to open. 4. Dog door opens 5. Fido goes outside 6. Fido does his business. 7. Fido goes back inside. 8. Dog door shuts automatically

  20. remote recognizer door:dogDoor door:dogDoor pressButton() recognize(String) door door 1 1 dogDoor open:bool allowedBark:String Open() Close() isOpen():bool setAllowedBark(string) getAllowedBark(string) Associations (has-a) allowedBarks * Bark sound:string getSound:string equals(Object bark): boolean

  21. Exercise • Divide into groups of 3 or 4 • Using the Homework Use Case Handout • Identify the nouns • Identify the verbs • What are some candidate classes? • What are some candidate methods?

  22. Homework • Use the classes you derived from the ATM Withdrawal Use Case(s) • Construct a class diagram for these classes.

  23. Finis

More Related