Presentation is loading. Please wait.

Presentation is loading. Please wait.

Software Engineering Design & modelling

Similar presentations


Presentation on theme: "Software Engineering Design & modelling"— Presentation transcript:

1 Software Engineering Design & modelling
Activity Diagram Interaction Overview Diagram

2 Introduction This chapter looks at how we can use the UML
to model the details of the work that objects do, both internally and in conjunction with other objects to model the details of computational processes Chapter outline: - Activity diagram Processes and threads Interaction Overview

3 Activity Diagrams

4 Topic Outline Activity diagram Definition Properties
Activity and action Transition Object flow Modelling activity diagram

5 Introduction An activity diagram is used to model the dynamic aspects of a system Activity diagrams can be attached to use cases communication Activity diagrams are used to model use cases and complex object workflows

6 In the context of use cases, activity diagrams are used to: -
Activity diagrams allow the readers to see the system’s execution, and how it changes direction based upon different conditions and stimuli. In this case, activity diagrams are used to model workflow for use cases. For the purpose of this lecture, we will see how activity diagrams can be used to take your use case to the next level.. In the context of use cases, activity diagrams are used to: - elaborate identify the pre- and post-conditions discover

7 Definition An activity diagram is essentially a flowchart, showing flow of control from activity to activity It involves modelling the sequential (and possibly concurrent) steps in a computational process modelling the flow of an object as it moves from state to state at different points in the flow of control Activity diagrams emphasize the flow of control from activity to activity Whereas, interaction diagram emphasize the flow of control from object to object

8 Properties Activity diagram commonly contains: -
Activity states and action states Transitions Swimlanes Object flow may also contain notes and constraints

9 Activity and action states
An activity is something that an object performs on an ongoing basis It is non-atomic, which means that it can be interrupted It can also be decomposed into other activities Activities ultimately result in some action An action is a set of executable computations that results in a change in the state of the system, or the return of a value to some objects, or both. It is atomic, meaning it cannot be interrupted It cannot be decomposed

10 The UML notation is the same for an activity and an action : a lozenge
It is assumed that an activity lasts for some duration of time, whereas an action generally takes an insignificant amount of time The UML notation is the same for an activity and an action : a lozenge Calculate shipping cost Update customer preferences Ship order activity shipCost = countyCode * subTotal isFulfilled = True action Example of some activities and actions associated with the Online Bookstore

11 Transitions When the action or activity of a state completes, flow of control passes immediately to the next action or activity states Transitions are used to show the path from one action or activity state to the next action or activity state A flow of control has to start and end someplace this can be specified by an initial state (a solid ball) and a stop state ( a solid ball inside a circle)

12 In the UML, a transition is presented as a simple directed line
initial state Activity / Action transition Activity / Action stop state

13 A transition between activities or actions can be modelled: -
sequentially by using branching and merging by using forking and joining

14 Branching and merging A branch is a decision point at which there are two or more possible paths of flow of control Each possible path out of a branch has a guard condition, which is a boolean expression that must be evaluated to true in order for the branch to be taken. Optionally, an “else” branch can also be inserted to account for a “none of the above” situation A guard condition is shown within a square bracket near a path out of the branch Similar to conditional state

15 A merge is a point at which two or more branched paths come together.
The UML represents both a branch and a merge with a diamond shape. Compute subtotal branching [ship outside of US] Look up country code [ship within of US] shipCost = regionPercent * subTotal shipCost = countryCode * subTotal merge Example of branching and merging for the scenario Process Customer’s Order of the Online Bookstore Compute new subtotal

16 Forking and Joining A fork is a splitting of a flow of control into two or more flows of control, each of which operates independently of, and concurrently with, the others. A join is a synchronization of two or more flows of control into one flow In UML, the symbol that represents both forks and joins is a long, thin, black rectangle called a synchronization bar.

17 Example of forking and joining associated with the Online Bookstore

18 Swim-lanes Group of activities and actions on an activity diagram can be grouped together with the help of vertical lines. In the UML, each group is called a swim-lane, which is simply a lane down which you can track activities and actions associated with a particular part of an organization. Each swim-lane has a name unique within its diagram The boundaries are simply conceptual and transitions may cross lanes

19 Retrieve books from inventory Update customer preferences
Receive order Shipping Marketing Accounting Retrieve books from inventory Update customer preferences Post General Ledger entries Calculate shipping costs swimlane Ship order swimlane Example of swimlanes

20 Object Flow Objects may be involved in the flow of control associated with an activity diagram. These objects may be specified in the activity diagram by using object flows Object flows are simply dependencies that show the details of how the object(s) involved in the various activities/actions are specifically affected

21 The UML provides two ways to show objects within object flows, involving: -
showing the new values for one or more attributes, using the notation (attribute = value) showing a “state” value in square brackets

22 An example of object flows

23 Modelling activity diagrams
Activity diagrams can be used in two ways: - To model a workflow focus on activities as viewed by the actors that collaborate with the system Workflows are used to visualize, specify, construct, and document business processes that involve the system being developed To model an operation used to model the details of a computation

24 Steps: Identify the activities and actions involved (to be rendered as activity and action states in the activity diagram) Identify activities that can be grouped together in order to form swimlanes For each swimlanes identified, give an appropriate name Render the transitions that connect these activity and action states Start with sequential flows Use branching and merging, or forking and joining, or both, if and where necessary Starting from the initial state, draw the activity diagrams until the final state If there are important objects that are involved, include them in the activity diagram

25 Calculate shipping cost
Receive order Shipping Marketing Accounting Retrieve books from inventory Update customer preferences Post General Ledger entries Calculate shipping cost Compute subtotal Look up country code [ship outside of US] [ship within of US] shipCost = regionPercent * subTotal shipCost = countryCode * subTotal Compute new subtotal Example of an activity diagram associated with the Process Customer’s Order scenario of the Online Bookstore Ship order

26 A simple example Develop an activity diagram based on the following narrative. The purpose of the Open Access Insurance System is to provide automotive insurance to car owners. Initially, prospective customers fill out an insurance application, which provides information about the customer and his or her vehicles. This information is sent to an agent, who sends it to various insurance companies to get quotes for insurance. When the responses return, the agent then determines the best policy for the type and level of coverage desired and gives the customer a copy of the insurance policy proposal and quote.

27 Steps: Identify the activities and actions involved (to be rendered as activity and action states in the activity diagram) Identify activities that can be grouped together in order to form swimlanes For each swimlanes identified, give an appropriate name Render the transitions that connect these activity and action states Start with sequential flows Use branching and merging, or forking and joining, or both, if and where necessary Starting from the initial state, draw the activity diagrams until the final state If there are important objects that are involved, include them in the activity diagram

28 Steps: - Identify the activities and actions involved
The purpose of the Open Access Insurance System is to provide automotive insurance to car owners. Initially, prospective customers fill out an insurance application, which provides information about the customer and his or her vehicles. This information is sent to an agent, who sends it to various insurance companies to get quotes for insurance. When the responses return, the agent then determines the best policy for the type and level of coverage desired and gives the customer a copy of the insurance policy proposal and quote.

29 Actions and activities identified
Prospective customers fill out an insurance application Prospective customers fill out form This information is sent to an agent… The application is sent to an insurance agent … who sends it to various insurance companies to get quotes for insurance Agent receives the application Agent sends it to various insurance companies to get quotes for insurance Insurance companies come up with/develop quotes When the responses return … Agent receives the quotes … agent then determines the best policy The agent decides best policy … and gives the customer a copy of the insurance policy proposal and quote. The agent sends the customer a copy of the insurance policy proposal and quote. Customer receives proposal and quotes

30 Identify activities that can be grouped together in order to form swimlanes. For each swimlanes identified, give an appropriate name Here, the activities and actions can be grouped together based on who performed those activities/actions Prospective customers fill out application The application is sent to an insurance agent Agent receives the application Agent sends it to various insurance companies to get quotes for insurance. Insurance companies come up with/develop quotes Agent receives the quotes, The agent decides best policy The agent sends the customer a copy of the insurance policy proposal and quote. Customer receives proposal and quotes

31 Group of activities and actions according to swimlanes: -
Prospective customer Prospective customers fill out application The application is sent to an insurance agent Customer receives proposal and quotes Insurance agent Agent receives the application Agent sends it to various insurance companies to get quotes for insurance. Agent receives the quotes The agent decides best policy The agent sends the customer a copy of the insurance policy proposal and quote. Insurance company Insurance companies come up with/develop quotes

32 Render the transitions that connect these activity and action states (sequential flows)
Prospective customer 1. Fill out application 2. Send in application 9. Receives proposal and quotes Insurance agent 3. Receives application 4. Sends to insurance companies. 6. Receives quotes 7. Decides best policy 8. Sends policy to prospective customer. Insurance company 5. Develop quotes

33

34 Case Study: On-Line Bookstore

35 On-line Bookstore is a web application that can be accessed by the store’s registered customer, whereby each customer can order books, review one or more books sold in the book store, and sell used books to other customers. Before performing any one of these transactions, the customer must first log-in into the system using their user id and password kept in their account. Problem: Draw the activity diagrams for the above system

36 Use Case Context Diagram
On-line Bookstore System Register <<extend>> (CustID) Check out Customer Order books <<include>> <<include>> Sell used books Log-in <<include>> Review books Use Case Context Diagram

37 Register

38 Log-in

39 Order

40 Check out

41 Sell used books

42 Process, threads & active objects

43 Introduction In the real-world, events may happen and things may take place all at the same time (concurrently). Example: - In a high rise building, there exists quite a number of tenants, each following their own agenda. But all must pass through a limited set of entrances. All must share the same bank of elevators. All must share the same electrical, water and parking facilities. If they are to work together optimally, they have to communicate and synchronize their interactions properly.

44 Therefore, when we model a system of the real-world, we must take into account its process view.
The process view encompasses the threads and processes that form the system’s concurrency and synchronization mechanism.

45 Flow of control There are two types of flow: - sequential and concurrent flow. In a purely sequential system, there is only one flow of control. meaning that one thing, and one thing only, can take place at a time Example: - When a sequential program starts, control is rooted at the beginning of the program and operations are dispatched one after another. No two operation can occur at the same time.

46 In a concurrent system, there is more than one flow of control
meaning that more than one thing can take place at a time Here, there are multiple simultaneous flow of control, each rooted at the head of an independent process or thread Because more than one flow of control can take place at a single time, one flow may interfere with another flow of control. This may cause concurrent systems to fail. Therefore, there must exists a form of synchronization to avoid this kind of situation. In the UML, each independent flow of control is modelled as an active object.

47 Active objects, processes and threads
An active object is a process or thread that can initiate control activity. A process is a heavyweight flow that can execute concurrently with other processes meaning that it is a thing known to the operating system and runs in an independent address space A thread is a lightweight flow that can execute concurrently with other threads within the same process meaning that it generally runs inside a process

48 An active object is an instance of an active class.
An active class, therefore, is a class whose instances are active objects. An active class represents an independent flow of control, whereas a plain class embodies no such flow. An active class shares the same properties as all other classes Active classes can be used to model common families of processes and threads. Active objects can communicate with one another by passing messages here, message passing must be extended to include certain concurrency semantics in order to synchronize the interactions among independent flows

49 Both active objects and active classes is represented in the UML using the class box, but with a thicker border. Active class Active object

50 In a system with both active and passive objects, there are four possible combinations of interaction that must be considered: - A message may be passed from one passive object to another A message may be passed (synchronously or asynchronously) from one active object to another A message may be passed from an active object to a passive object A message may be passed from a passive object to an active object

51 By modelling concurrent systems with active objects, each independent flow of control can be given a name. Furthermore, when an active object is created, the associated flow of control is started; when the active object is destroyed, the associated flow of control is terminated We can model the collaboration of active and passive objects by using interaction diagrams. When we model interactions that involve multiple flows of control, it is important to identify the process or thread that sent a particular message. In the UML, we can distinguish one flow of control from another by prefixing a message’s sequence number with the name of the process or thread that sits at the root of the sequence.

52 Example: - c : CNNNewsFeed s : StockTicker a1 : Analyst
c1 : postBreaingStory( ) s1 : postValue( ) s : StockTicker a1 : Analyst s2 : postAlert( ) m1 : postValue( ) m : AlertManager t : TradingManager i2 : postAlert( ) i : IndexWatcher a2 : Analyst i1 : postValue( )


Download ppt "Software Engineering Design & modelling"

Similar presentations


Ads by Google