Presentation is loading. Please wait.

Presentation is loading. Please wait.

Dynamic Models Sequence Diagrams Collaboration Diagrams Activity Diagrams.

Similar presentations


Presentation on theme: "Dynamic Models Sequence Diagrams Collaboration Diagrams Activity Diagrams."— Presentation transcript:

1 Dynamic Models Sequence Diagrams Collaboration Diagrams Activity Diagrams

2 Dynamic Modelling Static Model Express the static structure of a system including the classes, objects, and their relationships. Dynamic Model Express the behaviour of a system to demonstrate how the object interact dynamically at different times during the execution of the system. –control information –the sequences of events, –States and operations that occur within a system of objects, –usually involving the time dimension.

3 Dynamic Modelling Objects communicate with each other by sending messages to each other. A message is an operation call that one object invokes in another object. The way objects communicate and the effects of the communication are referred to as the dynamics of the system. –How objects collaborate through communication –How objects change state

4 UML Dynamic Models Communication among objects is called interaction. Can be described by 3 types of diagram: –Sequence Diagram: Shows how a sequence of messages are sent and received between objects. Focus is time. –Collaboration Diagram: Focus on the relationships between objects. –Activity Diagram: describes the activities of objects and their order.

5 UML Dynamic Models There is another dynamic model in UML that examines the interactions between objects from a single object’s point of view. State Diagram: describes which states an object can have during its lifecycle, and the behaviour in those states, along with what events cause the state to change; for example, and invoice can be paid (state paid) or unpaid (state unpaid).

6 Message Passing How are messages passed between objects?

7 Message Types Synchronous - invoked operation completes before control returns to caller. Asynchronous - caller continues processing while call is outstanding. Simple - Shows control passing between objects but without indicating precise mechanism involved.

8 State Diagram

9 All objects have a state. The state is the result of the previous activity performed by the object. The state is determined by the value of its attributes and links to other objects. An object changes state when something happens – called an event.

10 State Diagram Show how objects react to events and how they change their internal state. Has a starting point and can have several end points.

11 Components of a State Diagram l Event l something that happens at a point in time. An event has no duration. For example, received messages, time-outs, error exceptions. l State l an abstraction of the attribute values and links of an object l Activity l an operation that takes time to perform l closely associated with a state l Action l an operation performed on a state change

12 State Diagram State 2... State 1 do/activity 1 event [condition] /action name of event which causes transition an action that is performed when the event occurs a pre-condition before a transition occurs Starting point An end point (there can be several end points)

13 Relationships between State Diagram & Class Diagram A state diagram relates to ONE class within a class diagram. The received events are often messages that will have originated at one of the other classes with which the class in question has a relationship. Events are basically received messages and are therefore handled by a receiving class operation. Actions - happening upon a state transition - are usually class operations that may result in a message being sent to another object. Activities - happening within a particular class state - are usually class operations.

14 A State Diagram Example Passive Monitor do/ check detectors Detected do/ ring bell flash lights Alarm System access code typed in Intruder alert/ phone police correct access code typed in [30 seconds passed]

15 Another Example

16 Nested State Diagram State diagrams for an object may be nested, allowing the control mechanism to be viewed at different levels of abstraction. A nested state diagram is a form of generalisation on states.

17 Nested State Diagram OFF intruder detected active sensing passive sensing Alarm System Controller on power on power off code detect code Alarm time out On State diagram of alarm system controller with generalisation

18 Sequence Diagram

19 Illustrate how objects interact with each other. Has two axis: –Vertical shows time –Horizontal shows objects Reveals the interactions for a specific scenario.

20 Sequence Diagram :Control Unit :Sensor Intruder House Holder Switch On Valid Access Code Entry Police Person detected :Timer Start Invalid Access Code Timeout Notify activation lifeline X

21 Sequence Diagram Example

22 Collaboration Diagram

23 Like the sequence diagram the collaboration diagram show the interactions between objects. The sequence focuses on time, while the collaboration diagram focuses on ‘space’ (meaning the interactions and links between collaborating objects). Use a collaboration diagram when the objects and their links facilitate understanding the interaction. Use a sequence diagram when only the sequence needs to be shown.

24 Collaboration Diagram Consider the Class Diagram for the burglar alarm scenario: Control Unit Timer Sensor monitors signals 1 1..* Uses 1 1..*

25 Collaboration Diagram Example :Control Unit :Timer :Sensor InfraRed 1:person_detected() 1.1:Start()

26 Sequence & Collaboration Diagrams Sequence diagram emphasises Time. Collaboration diagram emphasises Interaction superimposed on links. –Clearer connection with the UML class diagram Both diagram types can be used to depict the execution of a Use-case.

27 Activity Diagram

28 UML Activity Diagram Capture actions and their results. Can place actions in swimlanes. A swimlane groups activities, with respect to who is responsible for them. Can be used to: –Capture work that will be performed when an operation is executing. –Show how a set of related actions may be performed an how they will affect objects around them. –Show how an instance of a use case may be performed –Show how a business works in terms of workers (actors), workflows, organisations, and objects.

29 Activity Diagram Notation An identified action or activity A decision branch An object either input to, or output from an action Signal Receipt - for receiving info. (usually from an object) Signal Send - denoting a signal being sent to an object

30 Activity Diagram Example Determine Closing Date and Interview Dates Job Start Date Manager [sufficient time] [insufficient time] Notify Job Spec. Advert [Create] Consider the recruitment Use-case introduced earlier in the course. The recruitment process could be described by the following activity diagram:

31 Activity Diagram

32 Consistency!! Ensure that all dynamic models are consistent with each other. Ensure that all dynamic models can be realised from the static models.


Download ppt "Dynamic Models Sequence Diagrams Collaboration Diagrams Activity Diagrams."

Similar presentations


Ads by Google