Now that we have seen use cases, the next behavioral
diagram I want to discuss is the sequence diagram. So
what is a sequence diagram? It is an interaction diagram
that emphasizes how objects communicate and the time ordering of
the messages between objects. To illustrate sequence diagrams in a
practical way, and hopefully in a clear way, I will
introduce them by creating an actual sequence diagram using an
example taken from our course management system. So let's see what
are the steps needed to build such a sequence diagram. The first
thing we want to do is place the objects that participate in
the interaction at the top of the diagram along the x-axis, and
you also want to place them in a specific way. You want
to place objects that initiate the interaction at the left, and place
increasingly more subordinate objects to the
right. So basically, this should reflect
the way the events will flow for the majority of the interactions
in the system. Next thing you want to do is to add
what is called the object lifeline. It's a vertical line that
shows the existence of objects over a period of time. And
it's normally represented with a dashed line, except for the outermost
object for which it is a solid line. Now that you
have your object lifeline you can start placing messages that these
objects send and receive. You want to put them along the
y-axis in order of increasing time, from top to bottom. And
you can also put a number on the message to further
clarify the sequence. So in this case what we're showing
is that the student will send the fill in info
message to the registration form. And this is the first
message in the sequence diagram, the first interaction. Then the student
might submit the form and this is also a message
that goes to the registration form. At this point, when
the submission takes place, the registration form will send the
message, so it will invoke some functionality in the registration manager.
Specifically you will invoke the add course functionality
and pass Joe, the name of the student and
Math 101 which is the specific course for which
Joe is registering. Then the registration manager will ask
the Math 101 course whether it accepts registrations,
and the interaction will continue. So that Math 101
will actually check for a specific offering, if everything
goes fine, you will receive an ack, you'll send
back the act to the registration manager and so
on. Until at the end, Joe will be registered for
Math 101. As you can see, it is very
easy to see how the interaction occurs between these different
objects at run time, dynamically. So what the behavior
of the system is for this specific scenario. So the
last notational element that I want to add to this
diagram is the focus of control. Which is this tall
thin rectangle, that shows the period of time
that an object is performing an action, either
directly or indirectly. So if we look at
the registration form, this is telling us that
the registration form is active for this amount
of time. And the same thing we can
do for the registration manager, the Math 101
course offering, and the Math 101 specific section.