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. target
base
SearchRecord
<< include>>
base
UpdateData
ReadDataBase
<< include>>
Rajeev Kumar, CSE, IIT - Kgp
5
Use Case << extend>> stereotypes: Implicitly incorporates the behaviour of the target use case. base
EOF Processing
<< extend>>
base
Invalid Record Processing Rajeev Kumar, CSE, IIT - Kgp
target
Record Read << extend>>
6
Use Case Diagrams Use Case for a financial trading system Update Accounts
Set Limits Analyze Risk
Trading Manager Trader
actor
Price Deal
<> <>
Valuation
Capture Deal
<<extends>>
use case
Accounting System
Limits Exceeded Rajeev Kumar, CSE, IIT - Kgp
Salesperson 7
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 Flow of Control
u : User 1 : login
p : LoginProcess 2 : spawn process
Sequence number
Message Rajeev Kumar, CSE, IIT - Kgp
k : Kernel
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 k : Kernel
p : LoginProcess
t : Terminal
request_terminal()
timee tim
grant_terminal() login( name, passwd ) validate_user() fork_user()
Focus of control
Life Line
Rajeev Kumar, CSE, IIT - Kgp
12
Collaboration Diagram
2 : grant_terminal()
t : Terminal
Message
1 : request_terminal() 3 : login( name, passwd )
Link
Object k : Kernel
p : LoginProcess 5 : fork_user() 4 : validate_user()
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 event
a..z
alphanumeric char Wait for input char delimiter
Final ( pseudo ) state
A simple statechart diagram to accept an alphanumeric string beginning with an alphabet Rajeev Kumar, CSE, IIT - Kgp
15
Statechart Diagrams Name
Action performed on entering state Action performed before exiting state Event NMI will trigger handleNMI While in this state do waitForCharacter
ReadCharacter entry / clearBuffer exit / returnCharacter NMI / handleNMI do / waitForCharacter IRQ7 / defer
Event IRQ7 deferred until suitable state is Rajeev Kumar, CSE, IIT - Kgp achieved
State 16
Statechart Diagrams Composite state abort
substate
Reading File Reading Char
valid char Idle
read
opened Opening
eof Close
initial Rajeev Kumar, CSE, IIT -Transition Kgp Statechart diagram for reading a file from substate 17
Statechart Diagrams Power off On Bootup
RAM Test
done concurrent states
Initialize Devices
Concurrent substates...
Detect new devices
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
FileSystem
MemManager
classes
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
Gateway
Internet
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
Use case
SetTime WatchRepairPerson ChangeBattery
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