Chapter 9 An ObjectOriented Analysis Case Study Dicks
Chapter 9 An Object-Oriented Analysis Case Study Dick’s Dive ‘n’ Thrive
Chapter Objectives n n n Review the OO Analysis Process Dick’s Dive ‘n’ Thrive Identifying Use Cases Building the Use Case Diagrams Developing initial Scenarios and Initial Classes n n Procedure for Building the Class Diagram Finding Initial Problem Domain Classes First Cut Scenarios of the Main Use Case Refining Scenarios and Classes n n Identifying Generalization / Specialization Hierarchies Identifying Whole-Part Hierarchies
Chapter Objectives Identifying and Specifying Attributes n Identifying Additional Relationships n Second-Cut Scenarios n Identifying Methods n Identifying Time-Dependent Behavior n Finalizing the Analysis Documentation n
OO Analysis Process n OO analysis process involves four main activities: n Create the system definition n Decide the system main functionality n n n use cases Build the class diagram Develop scenarios Develop corresponding sequence diagrams Finalize the analysis documentation
System Definition n n First create system definition When system definition is agreed to, most important use cases are identified Use cases provide a natural way of dividing the system into manageable units The goal is to identify what the system must do for the user to complete required work tasks
Further Steps in Analysis Process n With several iterations, two major activities are usually carried out parallel n n n Build a class diagram with the capability to satisfy the requirements Develop scenarios followed by sequence diagrams Complete final analysis documentation n n Assemble Thoroughly review with end users
Dick’s Dive ‘n’ Thrive Case Study n DDT: Small business that rents diving equipment and boats n Dick is company president Sells equipment and organizes diving trips n Hires consulting firm to develop a system to assist in conducting the business effectively n Consultant suggests focusing initially on the rental operations n n because that is where the problems and opportunities are
Identifying Use Cases After the brainstorming session with Dick, the consultants decide to determine the important or typical events. n The events translate into a list of use cases: n n n Rent equipment Return equipment Add new equipment Discard equipment Suspend equipment
Initial Use Case Diagram
Building Class Diagrams n The steps for developing the class diagrams are: 1. 2. 3. 4. 5. 6. 7. Review use cases and use case diagram Identify problem domain classes Identify generalization/specialization hierarchies and whole -part hierarchies to refine problem domain classes Identify important attributes Identify additional association relationships Identify classes’ custom methods Specify time-dependent behavior of objects
Initial Problem Domain Classes n n n Customer can rent diving equipment and boats Customer reviews what is available Customer makes decision about what to rent Rental contract is produced Store and customer sign rental contract
Initial Problem Domain Classes
Scenarios for Main Use Case n At least 4 scenarios and 4 sequence diagrams are required to model the interactions described so far: n n Rent boat to existing customer Rent boat to new customer Rent diving equipment to existing customer Rent diving equipment to new customer
First Scenario Event: Customer rents something n Use Case: Rent equipment n Scenario: Rent boat to existing customer n User asks Contract to create a new Contract object n Contract connects to correct Customer object n Contract connects to Boat object and gets information about amount to charge for the rental n Contract provides contract details in whatever form the user might require
Rent Boat to Existing Customer
Rent Boat to New Customer n n n n Scenario: Rent boat to new customer User asks Contract to create a new Contract object. Contract needs to create a new Customer object, so it asks Customer to create a new Customer object. Customer needs information to create itself, so the new Customer object asks the user for name, address, and other information. The user supplies the requested information, and then Customer supplies the information to Contract connects to the Boat object, and gets some information about the amount to charge for the rental. Contract provides the contract details in whatever form the user might require.
Rent Boat to New Customer
Refining Scenarios and Classes n n n Diving Equipment and Boat, are types of rental equipment. Consultants created general class, Rental Equipment. Results in generalization/specialization hierarchy. n example of bottom-up analysis approach
Refining Scenarios and Classes n n n Although specific attributes are not specified at this point, it is still necessary to think about needed attributes. By thinking about the attributes that are relevant for only some of the objects, the developers recognized a need for a subclass named Diving Suit. This is an example of top-down analysis.
Generalization / Specialization - Customer n n n After a careful look, structure looked unstable. Consultants realized diving related information could be contained in a class, Diving License. Similarly, boat related information could be related to Boat License. Customer object would then be associated with Diving License or Boat License or both. These association are strong relationships in the sense that neither object can exist without a corresponding customer object.
Multiple Inheritance Hierarchy
Generalization / Specialization n In the new approach, acquiring a new customer would mean adding two objects, (customer & Dive License or customer & Boat License) or adding three objects: Customer, Dive License, and Boat License.
Whole-Part Hierarchies - Boat Assembly n n Some boats are rented with trailer, some without a motor, and some with one or two motors. Trailer and motors always stay with the same boat n never rented by themselves
Whole-Part Hierarchies - Contract includes many items for equipment. n Each item is part of one contract. n Thus, there are two objects. n n n Contract its Contract Items
Class Diagram with Initial Attributes
Class diagram showing association relationships and customer methods
Second-Cut Scenarios n n n Event: Customer rents something Use Case: Rent Equipment Scenario: Rent boat assembly to existing customer n n n n The user asks contract to create a new contract object for an existing customer, based on a customer ID. Contract connects to the correct Customer object. The Customer object asks its Boat License object for license details and returns all customer information to the Contract object. Contract asks Contract Item to create a new object and to connect to the Contract Item asks the user for the boar ID since it is a boat rental contract, which the user supplies. Contract Item connects to the correct Boat Assembly and gets boat details, including the amount to charge for the rental , which it returns to Contract provides contract details to the user in whatever form the user might require.
Refined Sequence Diagram (Rent Boat Assembly to Existing Customer)
Rent Boat Assembly to New Customer n Scenario: Rent boat assembly to new customer n n The user asks Contract to create a new Contract object for a new customer. Contract knows it needs to create a new Customer, so it asks Customer to create a new Customer object. Customer needs information to create itself, so the new Customer object asks the user for name, address, and information about the boat license. The user supplies the requested information , the Customer object creates a new Boat License object, and then supplies all customer details to Contract.
Rent Boat Assembly to New Customer n n Contract asks Contract Item to create a new object and to connect to the Contract Item asks the user for the boat ID since it is a boat rental contract, which the user supplies. Contract Item connects to the correct Boat Assembly and gets boat details, including the amount to charge for the rental, which it returns to Contract provides contract details to the user in whatever form the user might require.
Rent Boat Assembly to New Customer
Identifying Time-Dependent Behavior n Object can be thought of as having a life cycle n n sequence of states the object can go through in its lifetime At some time the object is created. It then goes through various stages. Finally, it is deleted.
Review Questions 1. 2. 3. 4. 5. 6. What are the four activities of object-oriented analysis? Which of the activities are done in parallel? What are some ways to initially identify classes? What is the role of use cases and scenarios when building the requirement model? What is the relationship between a written scenario and a sequence diagram? What is the difference between the top-down approach and the bottom up approach for identifying generalization/specialization hierarchies and whole-part hierarchies?
Review Questions 7. 8. 9. 10. Explain why identifying a generalization/ specialization hierarchy requires identifying some attributes of the classes. Explain how scenarios and sequence diagrams are used to find messages and methods that are required. What graphical model documents time-dependent behavior? What are the reasons for clustering classes and defining packages?
Discussion Question • • In the DDT case, the consultants knew very little about the equipment rental business when they began. At the end of the case, Dick mentioned that they seemed to understand very well what the system needed to do. To what extent, then, is the analysis process a learning process for the analyst? Is the object-oriented approach a more natural approach for the analyst to use to learn something?
Discussion Questions n n An iterative, incremental approach to development is assumed in the DDT case. An important use case might be implemented as a prototype before addressing the requirements of additional use cases. To what extent is the class diagram relatively complete after developing just one use case in the DDT case? Why would an important use case involve most or even all of the problem domain classes of the system?
Discussion Questions n After completing the Rent equipment use case, what is the next use case you would choose to work on if you were running this project? Why?
Exercises 1. Write descriptions for the two scenarios of the Rent equipment use case that were not shown in the text: “rent diving equipment to an existing dive customer” and “rent diving equipment to a new customer. ” Create sequence diagrams to document the scenarios. 2. Consider whether a separate scenario should be written for the situation in which an existing boat customer wants to rent dive equipment for the first time. Write a description for the scenario and create a sequence diagram.
Exercises 3. All objects go through a life cycle. Create a statechart for Customer encompassing each of following: the customer is added, is in good standing, has equipment, is in default, and is deleted, Create a statechart for Contract.
Exercises 4. 5. 6. 7. What if Dick rented different types of boats, such as trailerable boats, motor boats, and row boats, each with different parts? Revise the class diagram to show this. What if Dick had two different types of contracts, long-term rentals(leases)and short –term rentals. Revise the class diagram to show this. Write a description of the scenario “add new diving equipment. ” Create a sequence diagram to document the scenario. What are some additional scenarios that might be included for the Add new equipment use case to handle all of the special situations? For ant one of the special situations, write a description of the scenario and create a sequence diagram.
- Slides: 40