1 SEQUENCE DIAGRAM EXAMPLE The domain model, showing the navigability of the associations, and the...

8
1 SEQUENCE DIAGRAM EXAMPLE SEQUENCE DIAGRAM EXAMPLE The domain model, showing the navigability of the associ ations, and the Reserve video (staff scenario) use-case description for the video sales and rental shop applicat ion 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 requ ired to realize this use case and the messages that are passed among the roles. Has 0..* RentalHistory IsFor 1 * Provides Reserves 1 * * * 1 * * 0..5 0..1 Buys quantity Review Customer Member RentalCopy MovieVideo CurrentRental * 1

description

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).

Transcript of 1 SEQUENCE DIAGRAM EXAMPLE The domain model, showing the navigability of the associations, and the...

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

1

SEQUENCE DIAGRAM EXAMPLESEQUENCE DIAGRAM EXAMPLE• The domain model, showing the navigability of the associatio

ns, and the Reserve video (staff scenario) - use case descr iption for the video sales and rental shop application are give

n below. Using only one boundary class, one control class an d any of the domain model entity classes , construct a seque

nce 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..1Buysquantity

Review Customer

Member

RentalCopyMovieVideo

CurrentRental

*

1

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

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.ActorsInvoked by StaffPreconditions1. The staff has successfully logged on to the system and the membe

r has less than 5 videos reserved.Basic Path1. 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.

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

3

SEQUENCE DIAGRAM EXAMPLE:SOLUTIONThe 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 a

nd 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 th

e 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).

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

4

SEQUENCE DIAGRAM EXAMPLESEQUENCE DIAGRAM EXAMPLE::SOLUTIONSOLUTION (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)

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

5

SEQUENCE DIAGRAM EXAMPLESEQUENCE DIAGRAM EXAMPLE:SOLUTION:SOLUTION

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

6

SEQUENCE DIAGRAMSEQUENCE DIAGRAM EXAMPLEEXAMPLE:SOLUTION:SOLUTION Flow of events for Reserve video (staff scenario) Use Case—A

nalysis 1. The Staff asks the ReserveVideoUI to allow a staff to reserve avideo. 2. The staff enters the member number and the movie ID.

3. The ReserveVideoUI asks the ReserveVideoMgr to reserve a co oo ooo ooooooooo oooooo.

4. The ReserveVideoMgr searches Member to get a reference to t he role whose member# equals the input member#.

5. The ReserveVideoMgr searches MovieVideo to get a reference t o the role whose movieID equals the input movieID.

6. The ReserveVideoMgr oooo ooo oooo oo oooooo oooooo ooo ooo 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 itsel f for the member.

9. The ReserveVideoMgr informs the Member of the new reservation.

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

7

SEQUENCE DIAGRAMSEQUENCE DIAGRAM EXAMPLEEXAMPLE:SOLUTION:SOLUTIONNotes:

1. Since we are only given the movieID as an input value,oo oooo oo oooooooo ooo oooooo oooooo ooo o ooooo ooo ooo o ssociatedMovieVideor ol e, whi ch knows about al l of i t s r ent al copi es byooo oo ooo ooooooooooo ooo ooooooo oooooooooo ooo ooo.

2. Since not all copies of a video may be available for rental oooooooooo oo oooo oo oooooo ooo oo ooooooooo ooooo ooooo ooo( ),.

sist he basi c pat h,we assume t hat t he sear ch succeeds infi ndi ng an avai l abl e copy.

3. There is no need to check how many videos a member h asreservedas t he pr econdi t i on st at es t hat he has l ess t han 5reserved.

-4. Since the navigability of the Reserves association is bi di rectional, iti s necessar y f or t he Member r ol e t o be i nf ormed of thef act t hat a newvi deo has been r eser ved and whi ch c opyhas been r eser ved.

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

8

SEQUENCE DIAGRAMSEQUENCE DIAGRAM :COMMON ERRORS:COMMON ERRORS• System” is not a role in a communication/sequencediagram.

• 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 w

ants the receiving role to do for it.