Professional Documents
Culture Documents
Pengajar:
Bayu Hendradjaya/Christine Suryadi
UML:
Unified Modeling Language
Introduction to UML
UML: pictures of an OO system
programming languages are not abstract enough for
OO design
UML is an open standard; lots of companies use it
History
Design notation of various kinds used
since programming began:
Flow charts, Pseudo code, Structure Diagrams
Diagram
UML
Structured
Diagram
Class Diagram
Component Diagram
Composite Structure
Diagram
Deployment Diagram
Object Diagram
Package Diagram
Behavior
Diagram
Use Case Diagram
Activity Diagram
State Machine Diagram
Interaction Diagram
Sequence Diagram
Communication Diagram
Interaction Overview
Diagram
Timing Diagram
6
Class Diagrams
http://www.agiledata.org/images/oo101ClassDi
Desain
agram.gif
dengan UML
attributes (optional)
should include all fields of the object
10
Class attributes
+ public
# protected
private
~ package (default)
/
derived
underline static attributes
derived attribute: not stored, but can
be computed from other attribute values
attribute example:
- balance : double = 0.00
11
11
+ public
# protected
- private
~ package (default)
underline static methods
parameter types listed as (name: type)
omit return_type on constructors and
when return type is void
method example:
+ distance(p1: Point, p2: Point): double
Desain dengan UML
12
12
Instance Specification
(Object)
13
Comments
represented as a folded note, attached to
the appropriate class/method/etc by a
dashed line
14
Associational
relationships
associational (usage) relationships
1. multiplicity (how many are used)
*
1
2..4
3..*
0, 1, or more
1 exactly
between 2 and 4, inclusive
3 or more
15
Multiplicity of
associations
one-to-one
one-to-many
16
Association
types
Car
1
1
Engine
aggregation
Book
composition
1
*
Page
Ticket
dependency
Random
17
Generalization
(Inheritance)
Supertype
Subtype 1
Subtype 2
Generalization: an inheritance
relationship
inheritance between classes
interface implementation
Desain dengan UML
18
Generalization Relationships
Generalization (inheritance)
relationships
hierarchies drawn top-down with
arrows pointing upward to parent
line/arrow styles differ, based on
whether parent is a(n):
class:
solid line, black arrow
abstract class:
solid line, white arrow
interface:
dashed line, white arrow
we often don't draw trivial / obvious
generalization relationships, such as
drawing the Object
class as a parent
Desain dengan UML
19
20
Simple
Aggregation
Rental Invoice
Abstract
Class
Rental Item
1..*
0..1
Composition
Simple
Association
Generalization
DVD Movie
VHS Movie
Video Game
Checkout Screen
21
StudentBody
+ main (args :
String[])
Address
Student
- streetAddress :
String
- city : String
- state : String
- zipCode : long
+ toString() : String
Desain dengan UML
22
Sequence Diagrams
24
25
Message
Self-call
Return
Delete
26
27
Representing objects
Squares with object type, optionally
preceded by object name and colon
write object's name if it clarifies the diagram
object's "life line" represented by dashed vert.
line
28
29
Messages, continued
message (method call) indicated by
horizontal arrow to other object
dashed arrow back indicates return
different arrowheads for normal / concurrent
(asynchronous) methods
30
Lifetime of objects
creation: arrow with
'new' written above it
notice that an object
created after the start of
the scenario appears lower
than the others
deletion: an X at bottom
of object's lifeline
Java doesn't explicitly
delete objects; they fall out
of scope and are garbagecollected
Desain dengan UML
31
Nesting
32
33
34
35
36
37
38
39
40
41
anOrderLin
e
getQuantity
getProduct
Found
message
aCustom
er
aProduct
aProduct
getPricingDetails
getBasePrice
Participan
t
Return
Lifeline
Activati
on
Self call
Messag
e
calculateDiscounts
getDiscountInfo
42
Object Diagram
43
Object Diagram
An object diagram is a snapshot of the
objects in a system at a point in time.
Because it shows instances rather than classes,
an object diagram is often called an instance
diagram.
When to use?
Object diagrams are useful for showing examples
of objects connected together.
In many situations, you can define a structure precisely
with a class diagram, but the structure is still difficult
to understand.
In these situations, a couple of object diagram
examples can make all the difference
Desain dengan UML
44
45
Class Diagram
Object Diagram
46
Package Diagram
47
Package Diagram
A package is a grouping construct
that allows you to take any construct
in the UML and group its elements
together into higher-level units.
Its most common use is to group classes
In programming terms, packages
correspond to such grouping constructs
as packages (in Java) and namespaces
(in C++ and .NET).
48
49
Dependencies in Package
50
Deployment Diagram
51
Deployment Diagram
Deployment diagrams show a
system's physical layout, revealing
which pieces of software run on what
pieces of hardware.
52
53
Activity Diagram
54
Activity Diagram
Activity diagrams are a technique to
describe procedural logic, business
process, and work flow.
In many ways, they play a role similar to
flowcharts, but the principal difference
between them and flowchart notation is
that they support parallel behavior.
55
56
Decomposing An Action
Actions can be decomposed
into subactivities
57
Subsidiary
Activity Diagram
58
Partitions
Activity diagrams tell
you what happens,
but they do not tell
you who does what
59
60
61
62
Software Lifecycle:
UML Can Be Used at Various Stages
Analysis: OOA
What is system to do? What services is it
to provide? Provide requirements for
designer.
Design: OOD
What will be the parts & structure of the
system? How will they interact? Provide
blueprint for programmer.
Programming: OOP
Desain dengan UML
63
64
65
Design phase
Design: specifying the structure of how a
software system will be written and function,
without actually writing the complete
implementation
A transition from "what" the system must do,
to "how" the system will do it
What classes will we need to implement a system
that meets our requirements?
What fields and methods will each class have?
How will the classes interact with each other?
Desain dengan UML
66
How do we design
classes?
class identification from project spec / requirements
nouns are potential classes, objects, fields
verbs are potential methods or responsibilities of a class
UML diagrams
class diagrams (today)
sequence diagrams
...
Desain dengan UML
67
67
Tugas
Untuk topik masing-masing:
Buat SKPL untuk pendekatan
berorientasi objek (template ada di
situs) yang mencakup:
Diagram use case dan skenario-nya
Untuk setiap use case:
Buat diagram kelas
Buat diagram activity (menggambarkan
seluruh alternatif skenario)
68
Closing
Slide Acknowledgement
Introduction to UML: Unified Modeling Language, Slide
Presentation of Ric Holt, U. Waterloo, March 2009 CS246
Design and UML Class Diagrams Slide presentation of
Marty Stepp, U. Washington, 2007.
TextBook:
Martin Fowler, UML Distilled: a brief guide to the standard object
modeling language. 3rd edition Addison-Wesley Professional, 2004.
Scott W. Ambler, The Object Primer: Agile Model Driven
Development with UML 2. 3rd edition Cambridge University Press,
2004.
69