-Now that we have seen use cases, the next behavioral - -2
-diagram I want to discuss is the sequence diagram. So - -3
-what is a sequence diagram? It is an interaction diagram - -4
-that emphasizes how objects communicate and the time ordering of - -5
-the messages between objects. To illustrate sequence diagrams in a - -6
-practical way, and hopefully in a clear way, I will - -7
-introduce them by creating an actual sequence diagram using an - -8
-example taken from our course management system. So let's see what - -9
-are the steps needed to build such a sequence diagram. The first - -10
-thing we want to do is place the objects that participate in - -11
-the interaction at the top of the diagram along the x-axis, and - -12
-you also want to place them in a specific way. You want - -13
-to place objects that initiate the interaction at the left, and place - -14
-increasingly more subordinate objects to the - -15
-right. So basically, this should reflect - -16
-the way the events will flow for the majority of the interactions - -17
-in the system. Next thing you want to do is to add - -18
-what is called the object lifeline. It's a vertical line that - -19
-shows the existence of objects over a period of time. And - -20
-it's normally represented with a dashed line, except for the outermost - -21
-object for which it is a solid line. Now that you - -22
-have your object lifeline you can start placing messages that these - -23
-objects send and receive. You want to put them along the - -24
-y-axis in order of increasing time, from top to bottom. And - -25
-you can also put a number on the message to further - -26
-clarify the sequence. So in this case what we're showing - -27
-is that the student will send the fill in info - -28
-message to the registration form. And this is the first - -29
-message in the sequence diagram, the first interaction. Then the student - -30
-might submit the form and this is also a message - -31
-that goes to the registration form. At this point, when - -32
-the submission takes place, the registration form will send the - -33
-message, so it will invoke some functionality in the registration manager. - -34
-Specifically you will invoke the add course functionality - -35
-and pass Joe, the name of the student and - -36
-Math 101 which is the specific course for which - -37
-Joe is registering. Then the registration manager will ask - -38
-the Math 101 course whether it accepts registrations, - -39
-and the interaction will continue. So that Math 101 - -40
-will actually check for a specific offering, if everything - -41
-goes fine, you will receive an ack, you'll send - -42
-back the act to the registration manager and so - -43
-on. Until at the end, Joe will be registered for - -44
-Math 101. As you can see, it is very - -45
-easy to see how the interaction occurs between these different - -46
-objects at run time, dynamically. So what the behavior - -47
-of the system is for this specific scenario. So the - -48
-last notational element that I want to add to this - -49
-diagram is the focus of control. Which is this tall - -50
-thin rectangle, that shows the period of time - -51
-that an object is performing an action, either - -52
-directly or indirectly. So if we look at - -53
-the registration form, this is telling us that - -54
-the registration form is active for this amount - -55
-of time. And the same thing we can - -56
-do for the registration manager, the Math 101 - -57
-course offering, and the Math 101 specific section. -- cgit 1.4.1