Software design - Lecture 24. The main topics covered in this chapter include: categories of UML diagrams; sequence diagram – dynamic diagram; notations in sequence diagram; vertical axis; graphical representation; return values; synchronous messages;...
1 Software Design Lecture : 24 Categories of UML Diagrams (3) Static Use case diagram Class diagram Dynamic Activity diagram Sequence diagram Object diagram State diagram Collaboration diagram Implementation Component diagram Deployment diagram Sequence Diagram – Dynamic Diagram It shows how objects communicate with each other over time The y are used to model object interaction in time sequence It reflect the ultimate path a particular use case can take for completion They are used to represent or model the flow of messages, events and actions between the objects or components of a system 5 Sequence Diagram It is used primarily to design, document and validate the architecture, interfaces and logic of the system by describing the sequence of actions that need to be performed to complete a task or scenario This diagram is a very useful design tools because it provide a dynamic view of the system behavior which can be difficult to extract from static diagrams or specifications 6 Notations in Sequence Diagram Sequence Diagram has two dimensions: Horizontal axis represents Objects of classes involved in class diagram Objects represent the Instance of Class with a format of Class name: Instance Name For instance Employee: e Usually class name is optional Vertical Axis Vertical line is draw to represents Life Line of Object (Time Sequence) The lifeline represents the existence of the object at a particular time If the object is created or destroyed during the period of time then its lifeline starts or stops at the appropriate point; otherwise it goes from the top to the bottom of the diagram If the object is destroyed during the diagram, then its destruction is marked by a large “X” Activation An activation (focus of control) shows the period of time during which an object is performing an action either directly or through a message An activation is shown as a tall thin rectangle whose top is aligned with its initiation time and whose bottom is aligned with its completion time Graphical Representation 10 Messages A message is a communication between objects that conveys information with the expectation that action will ensue. They are used to illustrate communication between different active objects of a sequence diagram The receipt of a message is normally considered an event 11 Messages (Cont.) A message is represented by an arrow between the life lines of two objects Self calls are also allowed The time required by the receiver object to process the message is denoted by an activationbox A message is labeled at minimum with the message name Arguments and control information (conditions, iteration) may be included 12 Return Values Optionally indicated using a dashed arrow with a label indicating the return value Don’t model a return value when it is obvious what is being returned, e.g. getTotal() Model a return value only when you need to refer to it elsewhere, e.g. as a parameter passed in another message Prefer modeling return values as part of a method invocation, e.g. ok = isValid() 13 Synchronous Messages Nested flow of control, typically implemented as an operation call The routine that handles the message is completed before the caller resumes execution :A :B doYouUnderstand() Caller Blocked yes return (optional) 14 Asynchronous In this type of message the flow is not interrupted and response is not awaited An asynchronous message is drawn with a halfarrowhead, that (one with only one wing instead of two) as shown below 15 Self Message We can call this type of message as recursive message ie Communication between same message A message from an object to itself, the arrow may start and finish on the same object symbol 16 17 Example with Self Call 18 Example of Sequence Diagram Sample Sequence Diagram : Client a : Assembly count(part) part : CatalogEntry Lifeline getNumber() Messages return number Activation( optional) control returns to the sender of the message (optional)