Anda di halaman 1dari 35

Sequence Diagram

Oleh :
Cosmas Haryawan
-- Pengenalan UML --
Sequence Diagram

 Menggambarkan interaksi antar objek di dalam dan di


sekitar sistem (termasuk pengguna, display, dan
sebagainya) berupa message yang digambarkan
terhadap waktu
 Biasa digunakan untuk menggambarkan skenario atau
rangkaian langkah-langkah yang dilakukan sebagai
respons dari sebuah event untuk menghasilkan output
tertentu.
 Diawali dari apa yang men-trigger aktivitas tersebut,
proses dan perubahan apa saja yang terjadi secara
internal dan output apa yang dihasilkan.
Sequence Diagram

 Sequence diagram terdiri atas:


 Dimensi vertikal (waktu)
 Dimensi horizontal (objek-objek yang terkait).
 Masing-masing objek, termasuk aktor, memiliki
lifeline vertikal.
 Diagram ini secara khusus berasosiasi dengan
use case diagram
 Memperlihatkan tahap demi tahap apa yang
seharusnya terjadi untuk menghasilkan sesuatu
didalam use case
Simbol yang digunakan
Simbol...
Partisipant / Object Lifeline

 Pada UML 1 disebut dengan nama Obyek


 Diletakkan dari kiri ke kanan
 Setiap Partisipant terhubung dengan lifeline
 Standar penamaan
 Instance Name : Class Name
Time / Lifeline

 Mewakili waktu pada arah vertikal, dimulai dari


atas ke bawah
 Garis putus-putus yang menempel di partisipant

lifeline
Action

 Mewakili sebuah eksekusi operasi dari


partisipant
 Kotak kecil segiempat di lifeline
 Panjang kotak berbanding lurus dengan durasi
activation
Message

 Message berpindah dari 1 lifeline ke lifeline


yang lain
 Message yan pertama kali muncul di SSD
terletak paling atas, kemudian message yang
berikutnya berada di bawahnya
 Terdapat 3 macam :
 Synchronus
 Asynchronus
 Reply / Return
Message…

 Synchronous
● Pesan yang dikirim oleh 1 obyek ke
obyek lain dan obyek pertama
menunggu sampai hasil aksi
selesai.

 Asynchronous
● Pesan yang dikirim oleh 1 obyek ke
obyek lain dan obyek pertama tidak
menunggu sampai hasil aksi
selesai.

 Reply/Return
● Menunjukkan nilai kembali dari
obyek ke obyek yang mengirim
pesan
Message …

 the analyst object makes a call to the system object which is an instance of
the ReportingSystem class.
 The analyst object is calling the system object's getAvailableReports
method.
 The system object then calls the getSecurityClearance method with the
argument of userId on the secSystem object, which is of the class type
SecuritySystem
 the secSystem object returns userClearance to the system object when the
getSecurityClearance method is called.
 The system object returns availableReports when the getAvailableReports
method is called.
Fun Example Objects

Sequence and Collaboration


Diagrams 12 12
Fun Example
Sequence diagram

Sequence and Collaboration


Diagrams 13 13
Fun Example
Sequence diagram

Sequence and Collaboration


Diagrams 14 14
Recursive
 Suatu Obyek yang memanggil dirinya sendiri
 Digambarkan dengan menambah kotak kecil pada
activation
 Cotoh : system object memberi pesan ke dirinya sendiri :
menentukan Laporan apa saja yang ada
Hapus Partisipant

 Partisipant bisa menghapus dirinya sendiri


atau bisa juga dihapuskan oleh object lain
Petunjuk membuat SD

1. Mengacu ke skenario Use Case / Stimulus-


Response
2. Identifikasi participant objects
3. Gambar lifelines untuk tiap object
4. Gambar duration tiap object pada lifeline
5. Tambahkan object messages dari atas ke
bawah pada diagram (time-based)
6. Check ulang diagram untuk
kelengkapannya
Guards
 Kondisi : suatu syarat agar message dikirim

 the guard is the text "[pastDueBalance = 0]." By having the


guard on this message, the addStudent message will only be
sent if the accounts receivable system returns a past due
balance of zero
Combined fragments

  digunakan untuk mengelompokkan


message, tergantung kondisi tertentu
  disebut juga Interaction Fragment
(Kerangka Interaksi)
 UML 2 specification mengidentifikasi 11
operator untuk combined fragments.
Format Combined
op (operator):
applied to the enclosed interaction(s)
(some operators require arguments, such as diagrams names,
parameters, constants and guards)

[guard]:
a boolean expression
op [:arguments] [ [guard] ] the interaction is executed according
to the guard’s value

diagram name | interaction interaction:


a (fragment of a) sequence diagram (it can
contain other frames)
if we need to enclose more interactions,
we’ll separate them with an outlined line
(see next slide)
diagram name:
needed if we want to refer to a diagram defined elsewhere
Contoh

 satu set interactions dipisahkan dengan garis


putus-putus
 interaction_i dijalankan jika guard_i bernilai
benar
op [guard_1]

interaction_1


[guard_n]

interaction_n
Operator Combined Fragment
 Alternatives (alt)
 choice of behaviors – at most one will execute
 depends on the value of the guard (“else” guard
supported)
 Option (opt)
 Special case of alternative  hanya berisi 2 pilihan
 Break (break)
 Represents an alternative that is executed instead of
the remainder of the fragment (like a break in a loop)
 Parallel (par)
 Concurrent (interleaved) sub-scenarios, fragmen
berjalan secara pararel
 Negative (neg)
 Identifies sequences that must not occur (interaksi
yang salah)
Operator…

 Critical Region (region)


 Fragmen tidak dapat disela dengan kejadian lain
pada participating lifeline
 Loop (loop)
 Optional guard: [<min>, <max>, <Boolean-
expression>]
 Tanpa Guard berarti tidak ada batas
Alternative
Option

if a student's past due balance equals zero, then the addStudent,


getCostOfClass, and chargeForClass messages are sent. If the student's past
due balance does not equal zero, then the sequence skips sending any of the
messages in the option combination fragment.
Loop
Ref
Ref…
Break
 almost identical in every
way to the option combined
fragment, with two
exceptions.
 a break's frame has a
namebox with the text
"break" instead of "option."
 when a break combined
fragment's message is to be
executed, the enclosing
interaction's remainder
messages will not be
executed because the
sequence breaks out of the
enclosing interaction
 Breaks are most commonly
used to model exception
handling
Pararel
Contoh SD
online-bookshop
Contoh SD Pemesanan Buku
Proses pemesanan buku

Cart Catalog Authentication Order

Customer

Put in shopping cart

Verify availability

Return availability

Buy shopping cart

Verivy customer

Return Customer chek

Send order
Contoh SD FB Otentifikasi
Diambil dari : Hendra
Diambil dari : Hendra

Anda mungkin juga menyukai