Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 SEQUENCE DIAGRAM EXAMPLE The domain model, showing the navigability of the associations, and the Reserve video (staff scenario) use-case description.

Similar presentations


Presentation on theme: "1 SEQUENCE DIAGRAM EXAMPLE The domain model, showing the navigability of the associations, and the Reserve video (staff scenario) use-case description."— Presentation transcript:

1 1 SEQUENCE DIAGRAM EXAMPLE The domain model, showing the navigability of the associations, and the Reserve video (staff scenario) use-case description for the video sales and rental shop application are given below. Using only one boundary class, one control class and any of the domain model entity classes, construct a sequence diagram that shows the roles required to realize this use case and the messages that are passed among the roles. Has 0..* RentalHistoryIsFor 1* Provides Reserves 1 * * * 1 * * 0..5 0..1 Buys quantity ReviewCustomer Member RentalCopyMovieVideo CurrentRental * 1

2 2 SEQUENCE DIAGRAM EXAMPLE (cont’d) Reserve video (staff scenario) This use case allows a staff to reserve up to 5 videos at a time for a member. Actors Invoked by Staff Preconditions 1. The staff has successfully logged on to the system and the member has less than 5 videos reserved. Basic Path 1. The use case begins when the user selects Reserve a video. 2. The system prompts the staff to input the member number and the video ID. 3. The staff inputs the member number and the video ID. 4. The system reserves a copy of the video for the member. 5. The use case ends.

3 3 SEQUENCE DIAGRAM EXAMPLE:SOLUTION The interactions in the sequence diagram are created as follows: The use case is started by the Staff actor selecting Reserve a video through the ReserveVideoUI (Message 1) (Line 1 of Reserve Video use case). The ReserveVideoUI displays the screen for entering the member number and the video ID (Message 2) (Line 2 of Reserve Video use case). The staff enters the member number and the video ID (Message 3) (Line 3 of Reserve Video use case). The ReserveVideoUI asks the ReserveVideoMgr to reserve the video for the member (Message 4) (Line 4 of Reserve Video use case). To reserve the video, the ReserveVideoMgr does the following: –First, it needs to get a reference to the member by searching through ใ Member using the provided member number (Message 5). (Note that we are given a member number, not a reference to a Member. Thus, we need to use the member number to find the corresponding (object) reference. Since this is the normal path for the use case we can assume that this search succeeds and we get the appropriate reference.) –Next, it needs to get a reference to the desired movie video by searching through MovieVideo using the provided video ID (Message 6).

4 4 SEQUENCE DIAGRAM EXAMPLE:SOLUTION (Again note that we are given a video ID, not a reference to a MovieVideo. Thus, we need to use the video ID to find the corresponding (object) reference. Since this is the normal path for the use case we can assume that this search succeeds and we get the appropriate reference.) – Having obtained the reference to MovieVideo, the ReserveVideoMgr next needs to get the references to its related rental copies (Message 7). – Next, the ReserveVideoMgr needs to find (a reference to) an available rental copy. (Note that a rental copy may already be rented or reserved.) It does this by searching through RentalCopy until an available copy is found. (Again, since this is the normal path for the use case we can assume that this search succeeds and we get the appropriate reference.) –Finally, the ReserveVideoMgr needs to inform both the RentalCopy (Message 9) and the Member (Message 10) about the reservation (i.e., give them a reference to each other) since the association is bi- directional in the domain model. Although not specified in the use case, it is reasonable to assume that the ReserveVideoUI informs the staff about the status of the reservation request (Message 11). The use case ends (Line 5 of Reserve Video use case)

5 5 SEQUENCE DIAGRAM EXAMPLE:SOLUTION

6 6 Flow of events for Reserve video (staff scenario) Use Case— Analysis 1. The Staff asks the ReserveVideoUI to allow a staff to reserve a video. 2. The staff enters the member number and the movie ID. 3. The ReserveVideoUI asks the ReserveVideoMgr to reserve a copy of the indicated video. 4. The ReserveVideoMgr searches Member to get a reference to the role whose member# equals the input member#. 5. The ReserveVideoMgr searches MovieVideo to get a reference to the role whose movieID equals the input movieID. 6. The ReserveVideoMgr gets the list of rental copies for the movie from MovieVideo. 7. The ReserveVideoMgr searches through the list of rental copies for an available one. 8. The ReserveVideoMgr asks the available Rental to reserve itself for the member. 9. The ReserveVideoMgr informs the Member of the new reservation.

7 7 SEQUENCE DIAGRAM EXAMPLE:SOLUTION Notes: 1. Since we are only given the movieID as an input value, we need to identify the rental copies for a movie via its associated MovieVideo role, which knows about all of its rental copies by way of the association Has between MovieVideo and RentalCopy. 2. Since not all copies of a video may be available for rental (either rented already or reserved), we need to search for an available copy. Since this is the basic path, we assume that the search succeeds in finding an available copy. 3. There is no need to check how many videos a member has reserved as the precondition states that he has less than 5 reserved. 4. Since the navigability of the Reserves association is bi- directional, it is necessary for the Member role to be informed of the fact that a new video has been reserved and which copy has been reserved.

8 8 SEQUENCE DIAGRAM :COMMON ERRORS System” is not a role in a communication/sequence diagram. We need to think object interaction, not procedural programming. We need entity roles if we want to access (database) data. 88 Entity roles do not interact with other entity roles (see Best Practices slide). The messages: –do not represent physical actions. –do not describe UI elements (e.g., textbox). –do not originate from entity roles. –are sent to only one instance of a role. –are named from the perspective of what the sending role wants the receiving role to do for it.


Download ppt "1 SEQUENCE DIAGRAM EXAMPLE The domain model, showing the navigability of the associations, and the Reserve video (staff scenario) use-case description."

Similar presentations


Ads by Google