You are on page 1of 16

Class Diagram

Compiled By :Umm-e-Laila

Lecture 25
Course Books

 Text Book:
The Complete Reference Java2 by Patrick Naughton
&Herbert Schildt

Appling UML and Patterns by Craig Larman By Robert Lafore

 Reference Books:
Beginning Java 2 by Ivor Horton

Thinking in Java by Bruce Eckel

UML Distilled by Martin Fowler

2
Course Instructors

 Umm-e-Laila ulaila2002@gmail.com
Assistant Professor, CED
Room Number: BS-04
Tel: 111-994-994, Ext. 536
Section B, D (Computer, Batch 2014)

 Muzammil Ahmad Khan mukhan@ssuet.edu.pk


Assistant Professor, CED
Room Number: BS-04
Tel: 111-994-994, Ext. 326
Section C,E (Computer, Batch 2014)
Course Instructors

 Moona Kanwal mkkhan221@hotmail.com


Assistant Professor, CED
Room Number: BS-02
Tel: 111-994-994, Ext. 536
Section A (Computer, Batch 2014)
Course Website

 http://sites.google.com/site/ulaila206

5
Marks Distribution

 Assignments + Quiz ______________ 10


 Mid Term ______________ 20
 Lab Work ______________ 20
 Semester Final Paper ______________ 50
 Total Marks ______________ 100

6
State Diagrams
 Objects can be either:
 Passive (current status of attributes)
 Active (status as it undergoes a continuous
transformation)
 State diagrams concentrate on the active states
of a single event-driven object
 An event occurs to force an object to make a
transition from one active state to another
 Events must be discrete rather than continuous
 Begin with externally observable states. Later,
you can refine these states into behaviours that
are not evident from outside the system
 State diagrams owe much to the theory of finite
automota
Basic UML State Diagram
State

Ready
Event

Initial stop [user quits] /ctr := 0


Pseudostate

Done Guard
Transition Action

stop
Final State
State Components
 Transitions:
 Three parts, all optional Event [Guard] / Action
 Events (or triggers)
 Guard is a logical condition returning “true” or
“false”. Transition occurs only if the condition is
true. Guards exiting a state must be mutually
exclusive
 Action represents a processes which occurs
quickly and is not interruptible
Label
 States:
 Two parts, label and activity do/activit
y
 Activity represents a process which is longer than
a transition action and can be interupted
Case Study: Voronoi Diagram State
Initiating Renderin
[no. particles = g
Generate n] Project Projection
Particles Particles complete

Centering
[no. iterations <= Find
m]
Centroids

Centroids
Repositioning calculated
[no. iterations >
m] Alter
Positions
Exercise: Control Panel State
 Create a state diagram from the following
narrative:
 The homeowner uses the keypad to key in a four-
digit password. The password is compared with the
valid password stored in the system. If the password
is incorrect, the control panel will beep once and
reset itself for additional input. If the password is
correct, the control panel awaits further action.
[password = incorrect] / beep & reset

Awaiting Password [password =


entered Validating correct]
Input
Compare
Password
Superstates
 If several states have the same transition
(e.g. cancel) then a superstate can enclose
them with a single transition
 Substates inherit the transitions of the
superstate
Active

Checking Waiting Dispatchin Cancelled


g
Static Conditional Branching
 A graphical shortcut for convenient rendering
of decision trees

Selling Happy

[value < 100] / reject bid

[value >= 200] / sell

[(value >= 100) & (value < 200)] / sell

Unhappy
Summary: Object-Behavioural Models
 State diagrams are good at describing the
behaviour of a single object across several use-
cases
 Interaction diagrams useful for describing the
behaviour of several objects in a single use
case
 Two flavours of interaction diagrams:
 Sequence Diagrams: Objects in the
horizontal, time in the vertical
 Collaboration Diagrams: Objects connected
by numbered events
 Roughly equivalent
 Use each object-behaviour diagram in the
situation for which it is most appropriate

You might also like