PART II

Rajeev Kumar
Rajeev Kumar, CSE, IIT - Kgp 1

Unified Modeling Language
Rajeev Kumar CSE, IIT-Kgp

Use Case
A Use Case describes a set of sequences. Each sequences indicates interaction of things external to the system ( Actors ) with the System.
A Use Case • Is an interaction of Actors and Systems • Executes tangible amount of work

Rajeev Kumar, CSE, IIT - Kgp

3

Use Case
collaboration use case Place Order

Order Management realization actor
Customer

generalization
Industrial Customer Rajeev Kumar, CSE, IIT - Kgp 4

Use Case
<< include>> stereotypes:
the base use case incorporates the behaviour of the target use case. The included use case cannot survive by itself.
base target << include>>

SearchRecord

ReadDataBase

base

UpdateData

<< include>>

Rajeev Kumar, CSE, IIT - Kgp

5

Use Case
<< extend>> stereotypes:
Implicitly incorporates the behaviour of the target use case.
base target

EOF Processing
base

<< extend>>

Record Read
<< extend>>

Invalid Record Processing
Rajeev Kumar, CSE, IIT - Kgp

6

Use Case Diagrams
Use Case for a financial trading system
Set Limits Trading Manager Trader Analyze Risk Price Deal Capture Deal Update Accounts

Accounting System

<<include>> <<include>>
Valuation

actor

<<extends>>

Salesperson 7

use case

Limits Exceeded Rajeev Kumar, CSE, IIT - Kgp

Interaction
• model the flow of control within an operation, class, component, use case or a system as a whole. • are used for modeling the dynamic aspects of a system • go beyond object diagrams to show messages and signals exchanged between objects.

Rajeev Kumar, CSE, IIT - Kgp

8

Interaction
Components of Interaction
u : User
1 : login

Flow of Control p : LoginProcess
2 : spawn process

k : Kernel

Sequence number

Message
Rajeev Kumar, CSE, IIT - Kgp

Object
9

Interaction
There are two equivalent types of Interaction Diagrams: Interaction Diagrams

Sequence Diagram

Collaboration Diagram

Rajeev Kumar, CSE, IIT - Kgp

10

Interaction
Sequence Diagrams • Shows an interaction arranged in time sequence • Shows the explicit sequence of messages • Is better for real-time specifications and for complex scenarios

Collaboration Diagrams
• Shows the relationships among objects • Is better for understanding all of the effects on a given object and for procedural design • Shows an interaction organized around the objects in the interaction and their links to each other • Does not show time as a separate dimension
Rajeev Kumar, CSE, IIT - Kgp 11

Sequence Diagram
objects t : Terminal p : LoginProcess k : Kernel

request_terminal() grant_terminal()

time time

login( name, passwd ) validate_user() fork_user()

Focus of control

Life Line
12

Rajeev Kumar, CSE, IIT - Kgp

Collaboration Diagram
t : Terminal
2 : grant_terminal()

Message

1 : request_terminal() 3 : login( name, passwd )

Link p : LoginProcess
5 : fork_user() 4 : validate_user()

Object k : Kernel

Sequence
Rajeev Kumar, CSE, IIT - Kgp 13

Statechart Diagrams
A Statechart Diagram : • Is used to model the dynamic aspect of a system • Shows a state machine • Shows the states an object / interaction goes through during its life It consists of: • States • Transitions
Rajeev Kumar, CSE, IIT - Kgp 14

Statechart Diagrams
Initial ( pseudo ) state numeric transition Wait for input char a..z Wait for input char delimiter Final ( pseudo ) state event alphanumeric char

A simple statechart diagram to accept an alphanumeric string beginning with an alphabet
Rajeev Kumar, CSE, IIT - Kgp 15

Statechart Diagrams
Action performed on entering state Action performed before exiting state Event NMI will trigger handleNMI While in this state do waitForCharacter Name

ReadCharacter
entry / clearBuffer exit / returnCharacter NMI / handleNMI do / waitForCharacter IRQ7 / defer State
16

Event IRQ7 deferred until suitable state is Rajeev Kumar, CSE, IIT - Kgp achieved

Statechart Diagrams
Composite state
abort Reading File Reading Char valid char Idle read opened Opening eof Close

substate

initial
Rajeev Kumar, CSE, Statechart diagram for reading a file IIT - Kgp Transition from substate 17

Statechart Diagrams
Power off
On Bootup done concurrent states Initialize Devices Detect new devices

RAM Test

Concurrent substates...

Rajeev Kumar, CSE, IIT - Kgp

18

Component Diagrams
Components : • Is a physical entity in a system • Is replaceable • Is part of a larger system - not stand-alone • Is a physical implementation of logical elements • Provides the realization of an interface

component

component name

Rajeev Kumar, CSE, IIT - Kgp

19

Component Diagrams
Os.dll

component

classes

FileSystem

MemManager

I/O Subsystem

Components can be used to implement the interface to classes
Rajeev Kumar, CSE, IIT - Kgp 20

Component Diagrams
Interface
Component 1 Component 2

Dependency

Realization

Component 1 uses Component 2 by accessing the interface exported by Component 2.

Rajeev Kumar, CSE, IIT - Kgp

21

Deployment Diagrams
• Used to model the physical aspects of the system • Design hardware artifacts • Shows configuration of runtime processing nodes Consists of : •Nodes •Dependency, Association & Relationship

Rajeev Kumar, CSE, IIT - Kgp

22

Deployment Diagrams
Database Internet
Gateway

A Network Deployment diagram

Cache Server

Cache Server

Local Area Network

Primary Server

Primary Server
Rajeev Kumar, CSE, IIT - Kgp

Client
23

Packages
• A Package is a grouping of model elements • Each element can be directly owned by a single package, so the package hierarchy is a strict tree. • Packages can reference other packages, so the usage net-work is a graph.

Rajeev Kumar, CSE, IIT - Kgp

24

Packages
Package
SimpleWatch

Actor
ReadTime

WatchUser

SetTime WatchRepairPerson ChangeBattery

Use case

A Package may consist of other modeling elements such Rajeev Kumar, CSE, IIT - Kgp as use cases.

25

Packages
GUI Window EventHandler MessageQueue A Generalization relation of packages... WindowsGUI GDI DC HAL XGUI XServer Widget

Rajeev Kumar, CSE, IIT - Kgp

26