Chapter1c UML Overview
Chapter1c UML Overview
UML
Use a formal process & tools to facilitate and
automate design steps:
Requirements
Specification
System architecture
Coding/chip design
Testing
Text: Chapter 1.4
Other resources on course web page.
Object-Oriented Design
Describe system/design as interacting objects
Across multiple levels of abstraction
Visualize elements of a design
Object = state + methods.
State defined by set of “attributes”
each object has its own identity.
user cannot access state directly
Methods (functions/operations) provide an abstract
interface to the object attributes.
Objects map to system HW/SW elements
Objects and classes
Class: an object type that defines
state elements for all objects of this type.
Each object has its own state.
Elements not directly accessible from outside
State values may change over time.
methods (operations) used to interact with all objects
of this type.
State elements accessed through methods
Object-oriented design principles
Some objects closely correspond to real-world objects.
Other objects may be useful only for description or
implementation.
Abstraction: list only info needed for a given purpose
Encapsulation: mask internal op’s/info
Objects provide interfaces to read/write the object state.
Hide object’s implementation from the rest of the system.
Use of object should not depend on how it’s implemented
Unified Modeling Language (UML)
Developed by Grady Booch et al.
Version 1.0 in 1997 (current version 2.4.1)
Maintained by Object Management Group (OMG) – www.omg.org
Resources (tutorials, tools): www.uml.org
Goals:
object-oriented;
visual;
useful at many levels of abstraction;
usable for all aspects of design.
Encourage design by successive refinement
Don’t rethink at each level
CASE tools assist refinement/design
UML Elements
Model elements
classes, objects, interfaces, components, use cases, etc.
Relationships
associations, generalization, dependencies, etc.
Diagrams
class diagrams, use case diagrams, interaction diagrams, etc.
constructed of model elements and relationships
Analyze
data
Measure
Actor0 T Supporting
(User) use cases Actor1
(System/CPU)
o Translate to algorithms for system design
DAQ system use case description
User
Select measure volts mode
Select measurement range or autorange
System
If range specified
Configure to specified gain
Make measurement
If in range – display results
If exceed range – display largest value and flash display
If auto range
Configure to midrange gain
Make measurement
If in range – display mode
If above/below range – adjust gain to next range and repeat
If exceed range – display largest value and flash display
UML class (type of object)
pixels
elements attributes/
menu_items state elements
mouse_click() operations/
draw_box methods
d1: Display
comment
attributes
Keypad CellularRadio
1 1
SendsNumberTo
SendsNumberTo
Aggregation/Composition Examples
List Rectangle
aggregation composition
Atom Point
1 compositions 0..*
aggregation
0..*
Contact
0..*
(child class)
Derived_class
UML
generalization
Base_class
(parent class)
Class derivation example
parent class
Display
base class pixels
elements
menu_items
pixel()
derived classes
set_pixel()
mouse_click()
draw_box
BW_display Color_display
child class child class
generalizations
Multiple inheritance
base classes
Speaker Display
Multimedia_display
Class
message message set
0..* 1
Diagram msg: ADPCM_stream
Contains count : integer
length : integer
(association)
ADPCM: adaptive differential pulse-code modulation
m1:message
msg = msg1 contains Msg:message set
Object length = 1102
Diagram (links) count = 2
m2:message
contains
msg = msg2
length = 2114
Object & Class Diagram Example
Object
diagram
Class
diagram
OO implementation in C++
(derive from UML diagram)
/* manipulate object d1 */
apixel = d1.pixel(0,0);
object method
d1.set_pixel(green,18,123);
Behavioral descriptions
Several ways to describe behavior:
internal view;
external view.
Dynamic models:
State diagram: state-dependent responses to events
Sequence diagram: message flow between objects over time
Collaboration diagram: relationships between objects
Specify:
inter-module interactions
order of task executions
what can be done in parallel
alternate execution paths
when tasks active/inactive
State machines
Similar to sequential circuit state diagrams
transition
a b
<<signal>>
mouse_click a
event b
declaration
event description
Call event
draw_box(10,5,3,2,blue)
c d
Timer event
tm(time-value)
e f
found object
object highlighted
finish
Sequence diagram
Shows sequence of operations over time.
Use to plan timing of operations
Relates behaviors of multiple objects.
Objects listed at top from left to right
Each object has a time line (shown as dashed line)
Focus of control (shown as a rectangle) indicates when object is
“active”
Actions between objects shown as horizontal lines/arrows
Sequence diagram example
Programs on a CPU: only one has control of CPU at a time
f1(p1)
f2(p2)
time
box = “focus
of control” return(r2)
return(r1)
Sequence diagram example
Display and menu co-exist (both “active”)
mouse_click(x,y,button)
which_menu(x,y,i)
time
box =
“focus of control” call_menu(i)
lifelines
Collaboration Diagram
Show relationship between object in terms of messages
passed between them
Objects as icons
Messages as arrows
Arrows labeled with sequence numbers to show order
of events
Example: Cell phone class diagram
Dialer Telephone Cellular Radio
:Speaker
1.2 EmitTone(code)
1* Digit(code)
2.1 Connect(pno)
Send:Button :Display