Week 11+12 Tool Lab Objectives Lab Outcomes Rational Rose The students shall be able to: Understand what are use-case and sequence diagrams Understand the visual modeling, and when to use these diagrams Understand the characteristics of use-case and sequence diagrams. Understand the concepts of actors, relationships, and scenarios (use-case main concepts). Understand the concepts of actor, message, destroy message, life line, return message, recursive message and control (sequence diagram main concepts). Draw use-case and sequence diagrams using Rational Rose. By the end of this week, it is expected that the students should be able to: Understand the visual modeling, and how to use use-case and sequence diagrams. Understand use-cases and draw suitable diagrams using Rational Rose tool. Understand how to apply dynamic modeling by sequence diagrams using Rational Rose. Part 1: Use-Case Diagrams Definitions Use Cases: A set of sequences of actions a system performs that yield an observable result of value to a particular actor o Actions: communicating with a number of actors performing calculations work inside the system Characteristics of use cases: o They are initiated by an actor. o They model an interaction between an actor and the system. o They describe a sequence of actions. o They capture functional requirements. o They should provide some value to an actor. o They represent a complete and meaningful flow of events. A use case may be used as a contract between developers and customers. Furthermore, you can derive user documentation from use cases Use cases are a good way to express functional requirements of the system. Each use case has a unique name. Name Types are: o Simple name o Path name 1 Notations Actors: in a use case diagram represents a role that someone may play, not an individual user of the system o The same person can play different roles (i.e. For example, if you work for a bank, you might be a LoanOfficer. If you do your personal banking there, as well, you'll also play the role of Customer. So, think about roles rather than people or job titles. Actors are rendered as stick figures. You can define general kinds of actors (such as Customer) and specialize them (such as CommercialCustomer) using generalization relationships. 2 Actor Relationship: Generalization can be used between actors. It is represented using an arrow pointing to the parent actor Use Case Scenario: Use case scenario is a specific example of a use case. It is an instance of a use case, as an object is an instance of a class To capture the possible scenarios, a software engineer would use a textual description of the use case Example o In University Information System, we’ve “Enroll students in courses” use case. o The following three possible sequences are called scenarios. A student wants to enroll in a course but they are missing a prerequisite A student wants to enroll in a course but the course is over-booked for the term A student wants to enroll in a course, they have the prerequisites and there is still room left Use Case Relationship: A simple line between an actor and a use case means that that actor is expected to perform that use case( Association relationship) 3 A line with arrow head from an actor to an actor defines a special kind of actor (Generalization). A line with arrow head from a use case to a use case is labeled as “include” or “extends”. o o Include RS: In the following example, “extending a loan” or “borrowing a copy of book” use cases include the “check for reservation” use case This means that “check for reservation” use case must be executed when either extending a loan or borrowing a copy of book is executed. So, neither “extending a loan” nor “borrowing a copy of book” use cases would be considered complete without check for reservation” use case” Extends RS: While developing use cases, you may find certain activities might be performed as a part of the use case but not mandatory for the use case to run. In the following example, if the student want to borrow a book (without exceeding the allowed number of books), there is no need to run the Refuse Loan case. Part 2: UML Use Case Exercise Example: Student Grades (1) (2) (3) (4) (5) (6) Identify the actors (i.e. name them): Are any of these actors is a specialized type of another more general actor? Identify the Use Cases (i.e. name them): Are any Use Cases always used by (an) other Use Case(s)? Are any of the Use Cases “sometimes” used by (an) other Use Case? Draw the described Use Case diagram, including all actors, Use Cases, and relationships. Be sure to use the correct notation for all actors, Use Cases, and relationships. Also be sure to label each and every actor, Use Case, and relationship (if it is an<< includes>>, <<extends>> or generalization relationship) 4 We are developing a system with which teachers can record and update grades of students. Teachers should also be able to distribute report cards. Here is a complete list of the requirements for the system: A teacher can record grades. Whenever grades are recorded, they are also saved to disk. A teacher can update grades. Whenever grades are updated, the existing grade is loaded. Then the updated grade is saved to disk. A teacher, a registrar, and/or a student can view grades. Whenever any of these people view grades, they must always log onto the system. If their log on fails, they must re-authenticate their user name and password. In this system we can find a part-time student who is a kind of student. A registrar can generate report cards; the teacher can distribute report cards. 5 Part 3: Sequence Diagram Definitions Sequence Diagram: is one of the interaction diagrams which used in the UML for modeling the dynamic aspects of systems. An interaction diagram shows an interaction, consisting of a set of objects and their relationships, including the messages that may be dispatched among them. o A sequence diagram is an interaction diagram that emphasizes the time ordering of messages. The sequence diagram is a table that shows objects arranged along the X axis and messages, ordered in increasing time, along the Y axis. Notations Actor A message: A Call message is a kind of message that represents an invocation of operation of target lifeline 6 Destroy Message: is a kind of message that represents the request of destroying the lifecycle of target lifeline Life Line: A lifeline represents an individual participant in the Interaction. o Objects may be created during the interaction. Their lifelines start with the receipt of the message stereotyped as create message. o Objects may be destroyed during the interaction. Their lifelines end with the receipt of the message stereotyped as destroy Return Message: is a kind of message that represents the pass of information back to the caller of a corresponded former message. 7 Recursive Message: is a kind of message that represents the invocation of message of the same lifeline. Its target points to an activation on top of the activation where the message was invoked from. Control: The focus of control is a tall, thin rectangle that shows the period of time during which an object is performing an action. o The top of the rectangle is aligned with the start of the action; the bottom is aligned with its completion (and can be marked by a return message) Part 4: UML Sequence Diagram Exercise: PURCHASE AN ITEM SCENARIO 1. The Buyer Clicks on “show the Item Type link “ on the SEARCH_RESULTS PAGE 2. The “isFixedPrice() “ operation In the FixedPrice_Item Class is called 3. The Fixed Price_Item Returns True to the Buyer Object 4. The Fixed Price_Item Class Views The message ”Fixed Price Item” on the Same page , 5. The Buyer clicks on the Link “view Item Info” on the same page 6. The viewItemDetails () operation of FixedPrice_Item class is Activated. 7. The item Details are retrieved to the Buyer on a new page called ITEM INFO PAGE 8. The Buyer click on add this item to shopping cart button on the ITEM INFO PAGE 9. The operation “addItemToSC()” of the ShoppingCart class is called 10. The Message”Item Is added” is returned and viewed on the buyer Machine 11. When the buyer order completed, he clicks on viewOrderDetails link on the shopping cart Items page. 12. The Operation getOrderInfo() of the Order Class is called 13. The details of Buyer order are viewd on the SHOPPING CART ITEMS PAGE 14. The buyer clicks on the link confirms order which causes the “confirmOrder() Operation of Order class to be called in order to process Buyer Order 15. The Order class calls the retrieveItems( ) service from the ShoppingCart Class 16. The Items are retrieved from ShoppingCart Class to the Order instance 17. The Order class requests calPrice( ) and calDiscount( ) services from FixedItem_Price class 8 18. The Order class calls the getShipCost() operation from Shipping Class 19. The Order class Calculates The Total Cost of items calling the calTotalPrice( ) on itself 20. The order class request the credit card data from the Buyer actor 21. The Buyer Enters his creditCard Data on the creditCard Form 22. the Order Class call checkCreditCardInfo() Operation (checking authentication data and credit amount) from the CreditCardClass, 23. The CreditCard Class returns True to the order class 24. The order Class debit the total price amount from credit card by calling the debitPrice() operation on itself 25. The order class view the messgage the operation completed successfully on the buyer machine 26. The Buyer Clicks on view Invoice Link on PAY FOR ITEMS PAGE 27. The get_Invoice() Operation is Called on Order class 28. The Invoice is retrieved as a result of purchasing 9 Buyer SEARCH_RESU LTS PAGE 1: 2: FixedPrice_Ite m 3: isFixedPrice() ITEM INFO PAGE 4: true order 5: viewItemDetails () 6: add this item to shopping cart shoping card 7: addItemToSC()" shiping 8: "Item Is added" 9: getOrderInfo() 10: viewOrderDetails 11: confirms order credet card 12: calPrice( ) 13: 14: calDiscount( ) 15: 16: the retrieveItems( ) 17: 18: getShipCost() 19: 20: calling the calTotalPrice( ) 21: checkCreditCardInfo() 22: 23: debitPrice() 24: the operation completed successfully 25: get_Invoice() 26: 10