Wednesday, July 13, 2011

Sequence Diagram

There are two comman interaction diagram

·         Sequence Diagram
·         Communication Diagram (a.k.a Collabaration diagram)

These two diagram tell excatly the same meaning in the anaylsis and design of system and any of these two diagram are need not both

Sequence diagram have have an explict time ordering and are linear where as in communication diagram have labelled time ordering and are geometric.

Interaction diagrams provide you with enough information to begin coding. The objects are instances of classes, so you need to define a class for each object. Messages generally equate to methods, and the method is placed in the class of the receiver (not the caller).

Sequence Diagram: Sequence are more comman, easy to create and are naturally organized and we don’t need to indicate the time ordering by annotating the meassages.

Elements of the Sequence Diagrams

Object lifeline: A lifeline is a rectangle with a verical line descending from the rectangle. The lifeline represens an instance of a class and the verticall descending line is a convenient place to attache incoming and outgoing messages. Adding multiple lifeline to a single diagram and attaching these to the time ordered message permits you to show all the classes and messages mecessary to complete a scenario described by use case. By eliminating ambiguous gaps or avoiding the repetition of classed and messages, you can get a whole solution, one scenario at a time.

Object lifelins can represent actors or objects. Both actors and object may or may not be actualized as code.
Activating lifeline : Objects have a lifetime. In the java implementation langauge, we create a object and we cann’t destroy the object. Destroying the objects is job of the garbage collector. But from the modeller (design) perspective we only care whe we begin using an object and when we are done using an object unless the object represents a finite resource. In both cases, the activation line represent the span of an object’s lifetime or scope for the practical purposes. It is also important to know than an object can be represented as being created and destroyed using a single lifeline.
The activation symbol is a vertical rectangle replacing the lifeline for the duration of that instance’s existence, keeping in mind that an object can be created and destroyed multiple times and that one lifeline is used to represent all instances of that class in a sequence

Sending Messages: Messages are directed lines connecting lifelines. The lines begins at one lifeline and the arrow points toward a lineline containing the message invoked. The message can begin and end on the same lifeline, this is a nested call. A filled-in triangle arrow head represents a synchronousmessage. A stick triangle arrow head represent an asynchronous message. A dashed line represents the return messages.

The other type of messages used in sequence diagram are:

Found Messages : A found message is a message with a known receiver but the sender is not known
Lost messages : A lost message is message with a know sender but there is not specified receiver.

Interaction Frame:
Interaction frames (or combined fragments) are new in UML version 2.0. Interaction frames are rectangular regions used to organize interaction diagrams (sequence and timing diagrams). Interaction frames can surround an entire interaction diagram or just part of a diagram. Each interaction frame is tagged with a specific word (or an abbreviated form of that word), and each kind of interaction frame conveys some specific information.

Alternatives fragments (i.e. conditional logic) only guard conditions evaluating to true will be execute
The guard indicates how many times this part will execute.
An invalid interaction
Equivalent to an alt with one condition (i.e. an if condition with no else statement
Fragments run in parallel (multithreading)
Reference to an interaction defined on another diagram
Critical region
Used to surround an entire sequence diagram, if desired.
Interaction frame diagram showing the loop frame
Complete sequence diagram example

No comments:

Post a Comment