Presentation is loading. Please wait.

Presentation is loading. Please wait.

Classification of UML Diagrams

Similar presentations


Presentation on theme: "Classification of UML Diagrams"— Presentation transcript:

1 Classification of UML Diagrams

2 Behavioral and Structural Perspectives of Unified Modeling Language UML
Any software system can have two aspects, static and dynamic. So a model is considered as complete when both the aspects are covered fully.

3 Structural Diagrams The structural diagrams represent the static aspect of the system. These static aspects represent those parts of a diagram which forms the main structure and therefore stable. Class Diagrams, Object Diagrams, Package Diagrams, Component Diagrams Deployment Diagrams

4 Behavioral Diagrams Behavioral diagrams basically capture the dynamic aspect of a system. Dynamic aspect can be described as the changing/moving parts of a system. Use case diagram Sequence diagram Collaboration diagram State chart diagram Activity diagram

5 Behavioral Diagram II Sequence Diagram

6 Interaction Diagrams One of the subsets of Behavioral diagrams
Interaction diagrams graphically depicts the way objects interact with each other to give different behaviors. Interaction diagrams are sub classified into Sequence diagrams and Collaboration diagrams Sequence Diagrams are special type of Interaction Diagram which apart from graphically showing the object interaction specially focuses on the sequence and timing of interaction between the objects. Collaboration Diagrams are special type of Interaction diagrams which apart from graphically showing the object interaction focuses on the spatial distribution of the objects.

7 The Purposes of Interaction Diagrams
The interactive behavior of the system is visualized . Visualizing interaction is a difficult task. So the solution is to use different types of models to capture the different aspects of the interaction. The purposes of interaction diagram To capture dynamic behavior of a system. To describe the message flow in the system. To describe structural organization of the objects. To describe interaction among objects.

8 Sequence Diagram A sequence diagram is an interaction diagram.
The diagram deals with some sequences, which are the sequence of messages flowing from one object to another. Interaction among the components of a system is very important from the implementation and execution perspective. Sequence diagram is used to visualize the sequence of calls in a system to perform a specific functionality.

9 Objects, Lifelines, essages, and other odds and ends
The objects and classes involved in the collaboration are shown at the top. We can distinguish objects from classes because objects have underlined names. The stick figure (actor) at left represents an anonymous object. It is the source and sink of all the messages entering and leaving the collaboration. Not all sequence diagrams have such an anonymous actor, but many do.

10 Objects, Lifelines, Messages, and Others
The dashed lines hanging down from the objects and the actor are called lifelines. A message being sent from one object to another is shown as an arrow between the two lifelines. Each message is labeled with its name. Arguments appear either in the parentheses that follow the name, or next to data tokens (the little arrows with the circles on the end). Time is in the vertical dimension, so the lower a message appears the later it is sent.

11 Typical Sequence Diagram

12 Example: Creation and Destruction
Creating an object. public class ShapeFactory { public Shape makeSquare() return new Square(); }

13 Example: Creation and Destruction
Releasing an object to the garbage collector public class TreeMap { private TreeNode topNode; public void clear() topNode = nil; }

14 Simple Loops

15 Cases and Scenarios This sequence diagram is too complex

16 Sequence Diagram Constitution Rules
Don't draw sequence diagrams like the diagram above. Nobody can read them. Nobody will read them. They're a huge waste of time. Learn how to draw a few smaller sequence diagrams that capture the essence of what you are trying to do. Each sequence diagram should fit on a single page, with plenty of room left for explanatory text.

17 public class Payroll{ private PayrollDB itsPayrollDB; private PayrollDisposition itsDisposition; public void doPayroll() { List employeeList = itsPayrollDB.getEmployeeList(); for (Iterator iterator = employeeList.iterator(); iterator.hasNext();) { String id = (String) iterator.next(); Employee e = ItsPayrollDB.getEmployee(id); if (e.isPayDay()) { double pay = e.calculatePay(); double deductions = e.calculateDeductions(); itsDisposition.sendPayment(pay - deductions); } } }} One small scenario

18 public class Payroll{ private PayrollDB itsPayrollDB; private PayrollDisposition itsDisposition; public void doPayroll() { List employeeList = itsPayrollDB.getEmployeeList(); for (Iterator iterator = employeeList.iterator(); iterator.hasNext();) { String id = (String) iterator.next(); Employee e = ItsPayrollDB.getEmployee(id); if (e.isPayDay()) { double pay = e.calculatePay(); double deductions = e.calculateDeductions(); itsDisposition.sendPayment(pay - deductions); } } }}

19 Advanced Concepts Loops and Conditions
Sequence diagram with loops and conditions

20 Sequence Diagram with Loops and Conditions -I
The payEmployee message is prefixed with a recurrence expression that looks like this: *[while id = idList.next()] The star tells us that this is an iteration; The message will be sent repeatedly until the guard expression in the square brackets is false.

21 Sequence Diagram with Loops and Conditions -II
The payEmployee message terminates on an activation rectangle that is touching, but offset from, the first. This denotes that there are now two functions executing in the same object. Since the payEmployee message is recurrent, the second activation will also be recurrent, so all the messages depending from it will be part of the loop.

22 Sequence Diagram with Loops and Conditions -III
Note the activation that is near the [payday] guard. This denotes an if statement. The second activation only gets control if the guard condition is true. If isPayDay returns true, then calculatePay, calculateDeductions, and sendPayment will be executed. Otherwise they won't.

23 Sending Messages to Interfaces
We have created an AsynchronousLogger But we still want to show the application using only the Logger interface.

24 Behavioral Diagram III
Collaboration Diagram

25 Collaboration Diagram
Collaboration diagram is another form of interaction diagram. It represents the structural organization of a system and the messages sent/received. Structural organization consists of objects and links. The purpose of collaboration diagram is similar to sequence diagram. But the specific purpose of the collaboration diagram is to visualize the organization of objects and their interaction.

26 Collaboration Diagrams
Collaboration diagrams contain the same information that sequence diagrams contain. Sequence diagrams make the order of the messages clear, Collaboration diagrams make the relationships between the objects clear

27 Collaboration Diagram
A link exists wherever one object can send a message to another. Traveling over those links are the messages themselves. The messages are labeled with the name of the message, its sequence number, and any guards that apply. The dot structure of the sequence number shows the calling hierarchy. The TreeMap.add function invokes the TreeMapNode.add function (message 1.1). Message 1.1 is the first message sent by the function invoked by message 1.

28 Sequence and Collaboaration Diagrams
For the Same Example

29 Behavioral Diagram IV State Diagram

30 State Diagrams There are two states named Locked and Unlocked.
Two events may be sent to the machine. The coin event means that the user has dropped a coin into the turnstile. The pass event means that the user has passed through the turnstile. The arrows are called transitions. They are labeled with the event that triggers the transition and the action that the transition performs. When a transition is triggered it causes the state of the system to change.

31 State Diagram Example If we are in the Locked state and we get a coin event, then we transition to the Unlocked state and we invoke the Unlock function. If we are in the Unlocked state and we get a pass event, then we transition to the Locked state and we invoke the Lock function. If we are in the Unlocked state and we get a coin event, then we stay in the Unlocked state and we call the Thankyou function. If we are in the Locked state and we get a pass event, then we stay in the Locked state and we call the Alarm function.


Download ppt "Classification of UML Diagrams"

Similar presentations


Ads by Google