download

Matakuliah
Tahun
: Konsep object-oriented
: 2009
Studi Kasus: Just a Line management
Pertemuan 11
Studi kasus
Just A Line Management
Tahap membuat class diagram
• Tahap membuat class diagram:
–
–
–
–
–
Identifikasikan obyek dan class turunannya
Identifikasikan atribut class
Mulai membuat kamus data
Identifikasikan operasi tiap class
Gunakan teknik CRC untuk mengkover tanggung jawab
dan kolaborasi
– Identifikasikan hubungan antar class, menggunakan
asosiasi, agregasi dan inheritance
– Iterasikan dan definisikan model
Identifikasikan obyek dan class
turunannya
•
Identifikasikan obyek fisik dan konsep yang potensial didalam problem domain
Just A Line management wishes to increase security, both their building and on site,
without antagonizing their employees. They would also like to prevent people who are
not part of the company from using the Just a Line car park.
It has been decided to issue identity cards to all employees, which their expected to
wear while on Just a Line sites. The card records the name, departement and
number the member of staff, and permit access to the Just A Line car park.
A barrier and card reader are placed at the entrance to the car park. The driver of an
approaching car inserts his or her numbered card in the card reader, which then
checks that number is known to the Just A Line system. If the card is recognized, the
reader send a signal to raise the barrier and the car able to enter the car park
A the exit, there also barrier, which raised when a car wishes to leave the car park.
When there are no spaces in the car park a sign at the entrance display Full and is
only switched off when a card is leaves.
Special visitors cards which record a number and the current date also permit acces
to the car park. Visitors cards may be sent out in advance, or collected from reception
. All visitors cards must be returned to reception when visitor leave Just A Line
•
Daftarkan obyek fisik dan obyek konsep yang ada diproblem domain
Just A Line
site
car park
number
card reader
system
sign
management
employee people
card
member of staff
entrance
signal
visitor
security
building
company
name
access
driver
exit
reception
departement
barrier
car
space
• Pelajari obyek dan buat obyek yang tidak berguna. Buang jika :
– Duplikat
– Tidak relevan
– Mempunyai arti ganda
– Terlalu umum
– Merupakan atribut
– Merupakan asosiasi
– Merupakan aturan(Roles)
– Merupakan implementasi
Duplikat
•
•
Jika ada dua atau lebih obyek yang berbeda nama tetapi menunjuk ke
hal yan sama, hanya satu yang digunakan, buang yang lainnya
Contohnya : employee/member of staff dan company/Just a Line
Just A Line
site
car park
number
card reader
system
sign
management
employee people
card
member of staff
entrance
signal
visitor
security
company
name
access
driver
exit
reception
building
departement
barrier
car
space
Tidak relevan
•
•
Obyek berada didalam problem domain tetapi tidak merupakan bagian
dari sistem, dibuang saja
Contohnya : management, site, company, visitor dan reception
management
site
car park
number
card reader
system
sign
security
building
company
entrance
signal
name
access
driver
exit
departement
barrier
car
space
visitor
reception
employee people
card
Mempunyai arti ganda (Vague)
•
Ketika sebuah kata dibaca dengan hati-hati, kadang sebuah kata tidak
mempunyai arti yang tepat sehingga tidak dapat dijadikan basis data
contohnya : security dan people
car park
number
card reader
system
sign
employee
card
entrance
signal
security
people
name
access
driver
exit
departement
barrier
car
space
Terlalu umum
• Sebuah kata seperti kata sistem tidak bisa menjadi class yang
berguna karena terlalu umum artinya:
car park
number
card reader
system
sign
employee
card
entrance
signal
name
access
driver
exit
departement
barrier
car
space
Attributes
• Sometime we discover a word is a part of some other class.
Such departement, name and number may be would be
attributes of the class card
car park
number
card reader
sign
employee
card
entrance
signal
name
access
driver
exit
departement
barrier
car
space
Asosiasi
• Kadang sebuah kata, seperti “ACCESS” keluar sebagai obyek,
tetapi sebetulnya kata tersebut mewakili relasi antar obyek
car park
card reader
sign
employee
card
entrance
signal
access
driver
exit
barrier
car
space
Aturan (Roles)
• Jangan ambil sebuah kata yang bersifat aturan(role) sebagai
anggota class diagram kata “driver” hanya berlaku sementara,
sesorang yang mengendarai kednaraan bermotor, jika sudah tidak
mengendarai tidak dapat disebut driver lagi
car park
card reader
sign
employee
card
entrance
signal
driver
exit
barrier
car
space
Implementasi
• Jangan mengambil sebuah kata sebagai class, jika kata tersebut
nantinya akan digunakan diwaktu implementasi contoh
“SIGNAL”
car park
card reader
sign
employee
card
entrance
signal
exit
barrier
car
space
• Find any missed class
– Is common sense if we have include a “sensor” into class,
because need sensor for each barrier to opened the barrier if
any car arrives and leaves.
• Potential class in Just A Line
Car Park
Staff Card
Visitor Card
Employee
Entrance
Exit
Card reader
Barrier
Full Sign
Space
Sensor
Car
Identifikasikan atribut sebuah class
• Identifikasikan aribut dari kata-kata.
• Kumpulkan data yang penting dan relevan tentang obyek tersebut
dan buang informasi yang tidak relevan
• Buang atribut jika dapat diturunkan dari class lain.
• Ketika kita memikirkan atribut. Sering kali kita menemukan bahwa:
– Detil yang sama dari dua class yang berbeda, misalnya
employee dengan staf card, artinya salah satunya tidak berguna,
dapat dibuang.
– Tidak ada atribut atau sesuatu yang dilakukan oleh class
tersebut, contohnya : entrance, exit, car and space, karena tidak
berguna dapat dibuang
Car Park
Staff Card
Visitor Card
Employee
Entrance
Exit
Card reader
Barrier
Full Sign
Space
Sensor
Car
Mulai membangun kamus data
Car Park : represent the physical car park and keeps count of the
number of spaces available
Staff Card : a card, issued to a member of the just a line staff. That record the staff member
number, name and departement. The number uniquely identifies. The card also permits access
to Just A Line car park
Visitor Card : a card, with permit access to Just A Line car park. Given to someone visiting the
company. The card record number and the current date. Visitor card may be send out in
advanced or collected from reception and all cards must be returned to reception when visitor
leave from Just A Line.
Card reader: a machine that read a card that is input and check the card number against a list
of valid number. If the card is valid , the reader sends a signal to raise the barrier
Barrier: a bar, which raise or lower itself according the signal received from either other
associate sensor or card reader.
Sensor: a device for detecting the presence of a card
Identifikasikan operasi yang
dilakukan class
Car Park
Capacity
spaces
inc.spaces()
dec.spaces()
Spaces left()
Gunakan CRC card untuk
menembukan tanggung jawab dan
kolaborasi
• CRC(classresponsibilitycollaboration)
• CRC card adalah
bagian dalam metode
pendekatan sistem
dengan nama
Responsibility-DrivenDesign
Full Sign
On : Boolean
Switch on()
Switch of()
• Tujuan dari Responsibility Driven Design adalah untuk
melihat semua fungsi didalam sistem dan membaginya
kedalam class.
• Tanggung jawab untuk menyediakan layanan bagi class
lain.
• Contoh:
– Class Full sign
bertanggung jawab
untuk menyala ketika
tidak ada lagi tempat
yang tersisa didalam
parkir dan padam
ketika ada tempat
kosong(tersedia)
Full Sign
On:Boolean
Switch on()
Switch off()
• Kadang sebuah class
berlaku sebagai server
dan memberikan
layanan kepada class
lain dan di lain waktu
berlaku sebagai client
menerima layanan dari
class yang lainnya
Car Park
Capacity
spaces
Full Sign
Inc.spaces()
Dec.spaces()
Spaces left()
Barrier
Up:boolean
Raise()
Lower()
On:boolean
Switch on()
Switch off()
• Sebuah contoh CRC Card dengan responsibilities
and collaborations
Barrier
Responsibillity
Collaborator
Raise()
Lower()
Sensor
Sensor
• Jika sebuah class tidak menjadi solusi yang fleksibel
Card reader
Card reader
Valid card nos.
Read card()
Read card()
Card OK()
Valid Card
Valid card nos.
Card OK()
Identifikasikan hubungan apakah
menggunakan association, aggregation atau
inheritance
• Asosiasi(association) : hubungan singkat antar obyek.
Student
Course
studies
0..*
Zero or one
Exactly one
Zero, one or many
One or more
An exact number
An a range
1..*
0..1
1(or ommited)
*, or 0..*
1..*
2,3,4, 24
2..3,4..6
Card reader
Read card()
1..*
1
Valid Card
Valid card nos.
Card OK()
• Agregasi(Aggregation): hubungan antar obyek ketika sebuah
class terdiri dari class yang lain (“part of”, ”consist of”, “made
up of”).
Car Park
1..*
2..*
2..*
Barrier
Sensor
1..*
Card Reader
Full Sign
• Inheritance: ketika
sebuah obyek
merupakan spesialisasi
dari class yang lain.
• Kadang orang lain
menyebutnya GenSpec
Card
card number
delete()
Visitor Card
current date
delete()
Staff Card
name
dept
expiry date
delete()
Car Park
1..*
Barrier
1..*
2..*
2..*
Full Sign
Sensor
Card Reader
1..*
1
Valid Card
Sebuah class diagram komplit Just A line
1..*
Card
Visitor Card
Staff Card
Kamus data(Data Dictionary)
• Kamus data merupakan sumber keterangan utama
tentang data.
• Kamus data menyediakan cara yang pasti untuk
mencatat data.
• Notasi kamus data:
– Harus mengekspresikan:
•
•
•
•
Urutan atribut yang muncul;
Atribut atau grup atribut yang berulang;
Atribut yang opsional;
Atribut merupakan pilihan yang harus dipilih;
• Notasi kamus data
Symbol
Arti
Keterangan
=
Terdiri dari (Consist
of)
Mengindikasikan permulaan definisi dari data item
+
Dan(And)
Pengabungan definisi komponen didalam urutan
{}
Satu atau
lebih(One on more)
Atribut mungkin berulang
()
Kosong atau
satu(Zero or one)
Atribut adalah opsional
[]
Pilihan(alternatives)
Isi yang berada dalam kotak merupakan pilihan yang dapat
dipilih, [ ]
|
Atau(Either.. Or)
Alternatif pilihan dipisahkan dengan garis vertikal
“”
Nilai
khusus(Specific
value)
Mengindikasikan pilihan khusus contoh [“Y”|”T”]
*..*
Komentar(comment
)
Komentar berada didalam tanda asterik
• Contoh employee obyek
:Employee
Number=JL104
Title = Mrs.
First name = Anne, Christine
Last name = Raines
Address = 46, ferry road.
Phone number = 1231312
Dept.= account
Jika dilukiskan dalam kamus data dapat berbentuk seperti ini
Employee = number + (title) + {first name}+ last name + address
+ phone number+ dept
Lebih tepatnya:
Employee = number + (title) + 1{ [ first name | title ] }3+ last name
+ address + phone number+ dept
Lebih dalam lagi
Dept. = [“Accounts” | “Design” | “Marketing” | “Administration” ]
• Mendeskripsikan dokumen
Just A Line Car Park List
name
Dept.
April 2003
Ext.
Car make
model
Number
Colour
Sue Preston
316
Renault
Clio
P0146JPG
Red
Harry Preston
360
Porsche
Carrera
JAL 1
Silver
Annie Raines
Account
465
Volvo
349
H4624KL
White
Chris doolan
Design
767
VW
Golf
6883PP
Green
Chris doolan
Design
767
Renault
Escape
65765
Grey
– Dari dokumen tersebut dapat didefinisikan kamus data
Car Park List = month + year+ {employee name + (dept). + ext +
1{ car make + car model + car number + car colour } 2}
Untuk mencegah kesalahan membaca dan membuat mudah dalam membacanya
maka kamus data tersebut ditulis :
Car Park List = Date + { entry }
Date = month + year
Entry = employee + { Car }2
Employee = name + ( dept ) + extension
Dept. = [“account” | “Design” | “Marketing” | “Administration” ]
Car = make + model + number + colour
Langkah berikutnya adalah
•
•
Membuatnya lebih detil dan
Gambarkan operasi nya ) contohnya pada halaman berikut:
Disarikan dari kamus data sistem parkir just a
line
Barrier = Barrier type + up
Barrier type = [“entrance”|”exit”]
up = [“true”|”False”]
raise: if the barrier not already raised, this operation takes an
argument an object if the barrier class and returns an object of the
same class. With the up attribute set to “true”. If the barrier is already
up the operation returns the error message “Barrier already raised”.
lower: if the barrier not already lower, this operation takes an
argument an object if the barrier class and returns an object of the
same class. With the up attribute set to “False”. If the barrier is
already down the operation returns the error message “Barrier already
lowered”.
Card = Number + [staff card|visitor card]
delete: this operation remove the card from the set of cards known to
Just A Line.
Car Reader = location
read card: this operation takes a card number as input and check it
against the number of known card in the Valid Card class
Car Park = capacity + spaces
capacity:*the total number of parking places in the car park*
spaces:*the number of currently free spaces in the car park*
inc.spaces: this operation check that the car park is not empty (number of spaces left is not
equal to capacity of the car park. In this the case the value of “space” increment by 1.
dec.spaces: this operation check that value of attributes in the car park is greather than 0. in
this the case the value of space decrement by 1
Full sign = location + on
on = [ “true”|”false”]
switch on:
switch off:
Sensor = Car Sensed
car sensed=[“true”|”false”]
sense car:if a car is detected by the sensor , this operation sets the car sensed attribute to
“true”
Staff Card = name + dept + expiry date
name = first name + last name
Dept. = [“Accounts” | “Design” | “Marketing” | “Administration” ]
expiry date = *date after which card is no longer valid*
delete: if the expiry date on the card has passed, this operation removes the card number
from the list of known to just a line.
Valid Card = known card * the set of cards whose numbers are recorgnized by Just A Line
Visitor card = current date * date that the card is issued*
delete:if the date on the card has passed, this operation removes the card number from the list of
known to just a line