Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Pengajar:
Bayu Hendradjaya/Christine Suryadi/Yani Widyani
Slide kuliah bisa di download dari
kuliah.itb.ac.id /app245(subyek IF2250)
UML:
Unified Modeling Language
The Unified Modeling Language (UML) is a
family of graphical notations that help in
describing and designing software systems,
particularly those built using object-oriented
(OO) style [Martin Fowler in UML Distilled]
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
Class Diagrams
http://www.agiledata.org/images/oo101ClassDiagram.gif
IF2250- Desain dengan
UML/Bayu Hendradjaya
attributes (optional)
should include all fields of the object
10
Class attributes
attributes (fields, instance variables)
visibility name : type [count] = default_value
visibility:
+
public
#
protected
private
~
package (default)
/
derived
underline static attributes
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
IF2250- Desain dengan UML/Bayu Hendradjaya
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
*
1
2..4
3..*
0, 1, or more
1 exactly
between 2 and 4, inclusive
3 or more
2. name
3. navigability
15
Multiplicity of associations
one-to-one
one-to-many
16
Car
Association types
1
1
Engine
Book
composition
1
*
Page
aggregation
dependency
Lottery
Ticket
Random
17
Generalization
(Inheritance)
Supertype
Subtype 1
Subtype 2
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
IF2250- Desain dengan UML/Bayu Hendradjaya
19
20
Simple
Class
Aggregation
Rental Invoice
Abstract
Class
Rental Item
1..*
1
0..1
Composition
Simple
Generalization
Association
Checkout Screen
DVD Movie
VHS Movie
Video Game
21
100
Address
Student
- firstName : String
- lastName : String
- homeAddress : Address
- schoolAddress : Address
+ toString() : String
- streetAddress : String
- city : String
- state : String
- zipCode : long
+ toString() : String
IF2250- Desain dengan UML/Bayu Hendradjaya
22
Sequence Diagrams
24
25
Create
New object
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 garbage-collected
31
Nesting
32
33
34
35
36
37
38
39
40
41
anOrder
calculatePrice
getQuantity
getProduct
Found
aCustomer
aProduct
Participant
Lifeline
aProduct
message
Activation
getPricingDetails
getBasePrice
Return
Self call
Message
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
I F2250- Desain dengan UML/Bayu Hendradjaya
44
Contoh Objek
Nama Objek
Nama Kelas
Novel ku : Buku
I sbn
Judul
Pener bi t
Juml ahHal aman
:
:
:
:
Nama at ribut
T ipe at ribut
Nilai At ribut
45
Novel ku : Buku
Komi k : Buku
46
Class Diagram
Object Diagram
47
Package Diagram
48
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).
49
50
Dependencies in Package
51
Deployment Diagram
52
Deployment Diagram
Deployment diagrams show a system's
physical layout, revealing which pieces of
software run on what pieces of hardware.
53
54
Activity Diagram
55
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.
56
Example of
Activity Diagram
57
Decomposing An Action
Actions can be decomposed into
subactivities
58
Subsidiary Activity
Diagram
59
Partitions
Activity diagrams tell you
what happens, but they
do not tell you who does
what
60
Activity
Diagram use
61
62
63
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
I F2250- Desain dengan UML/Bayu Hendradjaya
64
65
66
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?
67
UML diagrams
class diagrams (today)
sequence diagrams
... I F2250- Desain dengan UML/Bayu Hendradjaya
68
68
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)
69
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
TextBook::
Martin Fowler, UML Distilled: a brief guide to the standard object
modeling language. 3rd edition Addison-Wesley Professional, 2004.
Scott W. Ambler, The
I F2250- use-case
70