Optionally, a value that the receiver returns to the sender can be placed near the return arrow. If you want to show that the receiver has finished processing the message and returns control to the sender, draw a dashed arrow from receiver to sender. When a messages are used to represent method calls, each activation corresponds to the period during which an activation record for its call is present on the call stack. It starts when the message is received and ends when the object is done handling the message. The white rectangles on a lifeline are called activations and indicate that an object is responding to a message. A closed and filled arrowhead signifies that the message is sent synchronously. Most method calls in object-oriented programming languages are synchronous. Synchronous messageĪ synchronous message is used when the sender waits until the receiver has finished processing the message, only then does the caller continue (i.e. Near the arrow, the name and parameters of the message are shown. The arrow originates at the sender and ends at the receiver. When a target sends a message to another target, it is shown as an arrow between their lifelines. Note that the text of a class is not underlined, which is how you can distinguish it from an object. shared or static methods in some programming languages) can be sent to a class. Note however that the 'Type' part designates the type of the elements and not the type of the collection itself. Its basic notation isĪgain, a name and/or type can be specified. When you want to show how a client interacts with the elements of a collection, you can use a multiobject. A shorter name carries the same amount of information and doesn't clutter the diagram (e.g. don't use 'aStudent' for an instance of type Student). Try to avoid long but non-descriptive names when you're also specifying the type of the object (e.g. There are other anonymous objects of the same type and giving them names is the only way to differentiate them.
The UML sequence diagram gallery contains many examples, but here's a typical sequence diagram based on a system use case scenario : For each key collaboration, diagrams are created that show how objects interact in various representative scenarios for that collaboration. Lower equals Later).Ī popular use for them is to document the dynamics in an object-oriented system. An important characteristic of a sequence diagram is that time passes from top to bottom : the interaction starts near the top of the diagram and ends at the bottom (i.e. UML sequence diagrams are used to show how objects interact in a given situation.