Transparency Masters for Software Engineering: A

Download Report

Transcript Transparency Masters for Software Engineering: A

Catatan Kuliah
Rekayasa Perangkat Lunak
(Software Engineering)
Bagian 2
copyright © 2006
R.S. Pressman & Associates, Inc
M. Idham Ananta Timur, S.T., M.Kom.
Hanya digunakan di lingkungan Universtias
Hanya boleh digandakan untuk mahasiswa di lingkungan universitas
yang menggunakan buku Software Engineering: A Practitioner's Approach.
Selain itu dilarang keras menggandakan.
Presentasi, slide atau hardcopy tidak boleh digunakan untuk
short courses, seminar industri, atau kepentingan konsultasi.
These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 6/e and are provided
with permission by R.S. Pressman & Associates, Inc., copyright © 1996, 2001, 2005
1
Software Engineering: A Practitioner’s Approach,
6/e
Bab 11
Desain Level Komponen
copyright © 1996, 2001, 2005
R.S. Pressman & Associates, Inc.
For University Use Only
May be reproduced ONLY for student use at the university level
when used in conjunction with Software Engineering: A Practitioner's Approach.
Any other reproduction or use is expressly prohibited.
These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 6/e and are provided
with permission by R.S. Pressman & Associates, Inc., copyright © 1996, 2001, 2005
2
Apakah Komponen ?

OMG Unified Modeling Language Specification [OMG01]
mendefinisikan komponen sebagai



“… a modular, deployable, and replaceable part of a system that
encapsulates implementation and exposes a set of interfaces.”
Pandangan OO : Sebuah komponen terdiri dari
sekumpulan class2x yang berkolaborasi
Pandangan Konvensional: logika, struktur data internal
yang dibutuhkan untuk mengimplementasi logika proses
dan sebuah interface yang memungkinkan komponen
untuk dipanggil sehingga data dapat dimasukkan ke
dalamnya.
These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 6/e and are provided
with permission by R.S. Pressman & Associates, Inc., copyright © 1996, 2001, 2005
3
Komponen OO
a n a l y si s c l a ss
Pri n t Jo b
n u m b e rOf Pa g e s
n u m b e rOf Si d e s
p a p e rTy p e
m agnif ic at ion
p ro d u c t i o n Fe a t u re s
d e si g n c o m p o n e n t
c o m p u t e Jo b Co st( )
p a ssJo b t o Pri n t e r( )
c o m p u t e Jo b
Pri n t Jo b
i n i t i a t e Jo b
< < in t er f ace> >
co m p u t eJo b
comput ePageCost ( )
comput ePaper Cost ( )
comput ePr odCost ( )
comput eTot alJobCost ( )
< < in t er f ace> >
in it iat eJo b
buildWor kOr der ( )
checkPr ior it y ( )
passJobt o Pr oduct ion( )
elaborat ed design c las s
Print J ob
number Of Pages
number Of Sides
paper Type
paper Weight
paper Size
paper Color
magnif icat ion
color Requir ement s
pr oduct ionFeat ur es
collat ionOpt ions
bindingOpt ions
cover St ock
bleed
pr ior it y
t ot alJobCost
WOnumber
comput ePageCost ( )
comput ePaper Cost ( )
comput ePr odCost ( )
comput eTot alJobCost ( )
buildWor kOr der ( )
checkPr ior it y ( )
passJobt o Pr oduct ion( )
These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 6/e and are provided
with permission by R.S. Pressman & Associates, Inc., copyright © 1996, 2001, 2005
4
Komponen Konvensional
design component
getJobData
ComputePageCost
accessCostsDB
elaborat ed module
PageCost
in: numberPages
in: numberDocs
in: sides= 1 , 2
in: color=1 , 2 , 3 , 4
in: page size = A, B, C, B
out : page cost
in: j ob size
in: color=1 , 2 , 3 , 4
in: pageSize = A, B, C, B
out : BPC
out : SF
g e t Jo b Dat a ( n u m b e rPag e s, n u m b e rDo cs,
sid e s, co lo r, p ag e Size , p ag e Co st )
acce ssCo st sDB (j o b Size , co lo r, p ag e Size ,
BPC, SF)
co m p u t e Pag e Co st( )
j o b size ( JS) =
n u m b e rPag e s * n u m b e rDo cs;
lo o ku p b ase p ag e co st ( BPC) -->
acce ssCo st sDB ( JS, co lo r) ;
lo o ku p size fact o r ( SF) -->
acce ssCo st DB ( JS, co lo r, size )
j o b co m p le xit y fact o r ( JCF) =
1 + [ ( sid e s-1 ) * sid e Co st + SF]
p ag e co st = BPC * JCF
These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 6/e and are provided
with permission by R.S. Pressman & Associates, Inc., copyright © 1996, 2001, 2005
5
Prinsip2x Desain Dasar







The Open-Closed Principle (OCP). “sebuah modul[komponen] harus
terbuka untuk ekstensi, namun tertutup untuk modifikasi.
The Liskov Substitution Principle (LSP). “Subclass harus dapat
disubstitusi oleh basis class nya.
Dependency Inversion Principle (DIP). “Tergantung pada abstraksi,
tidak tergantung pada konkret.”
The Interface Segregation Principle (ISP). “banyak interface spesifik
client lebih baik daripada satu interface general purpose.
The Release Reuse Equivalency Principle (REP). “Bagian-bagian kecil
yang dapat digunakan kembali adalah bagian-bagian kecil yang akan
direlease.”
The Common Closure Principle (CCP). “Class2x yang berubah bersamasama adalah milik bersama.”
The Common Reuse Principle (CRP). “Class2x yang tidak digunakan
kembali bersama-sama tidak dikelompokkan bersama.”
Source: Martin, R., “Design Principles and Design Patterns,” downloaded from http:www.objectmentor.com, 2000.
These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 6/e and are provided
with permission by R.S. Pressman & Associates, Inc., copyright © 1996, 2001, 2005
6
Panduan Desain

Komponen


Interfaces


Konvensi penyebutan nama harus ditentukan untuk
komponen2x yang menjadi bagian dari model arsitektur dan
kemudian disempurnakan dan diuraikan sebagai bagian dari
model level komponen
Interface menyediakan informasi penting mengenai komunikasi
dan kolaborasi (yang akan membantuk kita mendapatkan OCP)
Dependencies dan Inheritance

Adalah ide yang bagus untuk membuat model dependency dari
kiri ke kanan dan intheritance dari bawah ke atas.
These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 6/e and are provided
with permission by R.S. Pressman & Associates, Inc., copyright © 1996, 2001, 2005
7
Kohesi

Pandangan konvensional:


OO view:


Sebuah modul tunggal
cohesion menyatakan bahwa sebuah komponen
atau class melakukan enkapsulasi hanya atribut2x
dan operasi2x yang punya kaitan erat dengan yang
satu yang lain dan dengan class atau komponen itu
sendiri.
Level kohesi







Fungsional
Lapisan/Layer
Komunikasi
Sekuensial
Prosedural
Temporal
utility
These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 6/e and are provided
with permission by R.S. Pressman & Associates, Inc., copyright © 1996, 2001, 2005
8
Coupling

Pandangan Konvensional:


Pandangan OO :


Derajat dimana sebuah komponen terhubung
dengan komponen lain dan dengan dunia eksternal
Pengukuran kualitatif terhadap derajat dimana
class2x saling terkait satu dengan yang lain
Level coupling









Content
Common
Control
Stamp
Data
Routine call
Type use
Inclusion or import
External
These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 6/e and are provided
with permission by R.S. Pressman & Associates, Inc., copyright © 1996, 2001, 2005
9
Component Level Design-I





Langkah 1. Identifikasi semua class2x desain yang
berkaitan dengan domain permasalahan.
Langkah 2. Identifikasi semua class2x desain yang
berkaitan dengan domain infrastruktur.
Langkah 3. teliti semua class2x desain yang tidak dikenali
sebagai komponen yang dapat digunaka kembali.
Langkah 3a. Tentukan detail pesan ketika class2x atau
komponen berkolaborasi.
Step 3b. Identifikasi interface yang tepat untuk setiap
komponen.
These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 6/e and are provided
with permission by R.S. Pressman & Associates, Inc., copyright © 1996, 2001, 2005
10
Component-Level Design-II






Langkah 3c. Teliti atribut2x dan tentukan tipe2x data dan
struktur data yang dibutuhkan untuk mengimplementasi
mereka.
Langkah 3d. Gambarkan aliran proses di setiap operasi
secara detail.
Langkah 4. Gambarkan sumber data persistence (database
dan file) dan identifikasi class2x yang diminta untuk
mengelolanya.
Langkah 5. Kembangkan dan perinci representasi perilaku
untuk class atau komponen.
Langkah 6. Teliti diagram deployment untuk menyediakan
detail implementasi tambahan.
Step 7. Faktorkan setiap representasi desain level
komponen dan selalu perhatikan alternatif2x.
These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 6/e and are provided
with permission by R.S. Pressman & Associates, Inc., copyright © 1996, 2001, 2005
11
Collaboration Diagram
:ProductionJob
1: buildJob ( WOnumber )
2: submitJob ( WOnumber )
:WorkOrder
:JobQueue
These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 6/e and are provided
with permission by R.S. Pressman & Associates, Inc., copyright © 1996, 2001, 2005
12
Refactoring
computeJob
PrintJob
initiateJob
WorkOrder
<<interface>>
initiateJob
ap p ro p riat e at t rib u t e s
getJobDescriiption
buildWorkOrder ()
buildJob
p assJo b To Pro d u ct io n ( )
ProductionJob
submitJob
JobQueue
ap p ro p riat e at t rib u t e s
checkPriority ()
These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 6/e and are provided
with permission by R.S. Pressman & Associates, Inc., copyright © 1996, 2001, 2005
13
Activity Diagram
validat e at t ribut es
input
ac cessPaperDB (weight )
ret urns baseCost perPage
paperCost perPage =
baseCost perPage
s ize = B
paperCost perPage =
paperCost perPage * 1 . 2
s ize = C
paperCost perPage =
paperCost perPage * 1 . 4
size = D
paperCost perPage =
paperCost perPage * 1 . 6
color is cust om
paperCost perPage =
paperCost perPage * 1 . 1 4
c olor is st andard
ret urns
( paperCost perPage )
These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 6/e and are provided
with permission by R.S. Pressman & Associates, Inc., copyright © 1996, 2001, 2005
14
Statechart
b eh avio r w it h in t h e
st at e b u ild in g Jo b Dat a
d at aIn p u t In co mp let e
buildingJobDat a
ent ry/ readJobDat a ()
exit / displayJobDat a ()
do/ checkConsist ency()
include/ dat aInput
d at aIn p u t Co mp let ed [ all d at a
it ems co n sist en t ] / d isp layUserOp t io n s
comput ingJobCost
ent ry/ comput eJob
exit / save t ot alJobCost
j o b Co st Accep t ed [ cu st o mer is au t h o rized ] /
g et Elect ro n icSig n at u re
f ormingJob
ent ry/ buildJob
exit / save WOnumber
do/
submit t ingJob
ent ry/ submit Job
exit / init iat eJob
do/ place on JobQueue
j o b Su b mit t ed[ all au t h o rizat io n s acq u ired ] /
p rin t Wo rkOrd er
These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 6/e and are provided
with permission by R.S. Pressman & Associates, Inc., copyright © 1996, 2001, 2005
15
Object Constraint Language (OCL)


Melengkapi UML dengan memungkin software engineer
menggunakan grammar dan syntax formal untuk membangun
penyataan yang tidak ambigu tanpa elemen2x model desain
Pernyataan bahasa OCL yang paling sederhana dibangun
dengan 4 bagian ::




(1) sebuah context yang menyatakan situasi terbatas dimana
statemen tersebut valid;
(2) sebuah property yang menampilkan beberapa karakterstik dari
konteks(mis jika context adalah class, properti adalah atribut)
(3) sebuah operation (mis aritmetika) yang memanipulasi atau
menentukan properti, dan
(4) keywords (mis if, then, else, and, or, not, implies) yang
digunakan untuk ekspresi kondisional.
These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 6/e and are provided
with permission by R.S. Pressman & Associates, Inc., copyright © 1996, 2001, 2005
16
Contoh OCL
context PrintJob::validate(upperCostBound :
Integer, custDeliveryReq :
Integer)
pre: upperCostBound > 0
and custDeliveryReq > 0
and self.jobAuthorization = 'no'
post: if self.totalJobCost <= upperCostBound
and self.deliveryDate <= custDeliveryReq
then
self.jobAuthorization = 'yes'
endif
These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 6/e and are provided
with permission by R.S. Pressman & Associates, Inc., copyright © 1996, 2001, 2005
17
Desain Algoritma


Aktivitas desain paling dekat dengan
coding
pendekatan:




review gambaran desain untuk komponen
Gunakan langkah-langkah penyempurnaan
untuk mengembangkan algoritma
Gunakan pemrograman terstruktur untuk
implementasi logika prosedural
Gunakan ‘formal methods’ untuk
membuktikan logika
These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 6/e and are provided
with permission by R.S. Pressman & Associates, Inc., copyright © 1996, 2001, 2005
18
Langkah2x Penyempurnaan
open
walk to door;
reach for knob;
open door;
walk through;
close door.
repeat until door opens
turn knob clockwise;
if knob doesn't turn, then
take key out;
find correct key;
insert in lock;
endif
pull/push door
move out of way;
end repeat
These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 6/e and are provided
with permission by R.S. Pressman & Associates, Inc., copyright © 1996, 2001, 2005
19
Model Desain Algoritma


Menampilkan algoritma pada level detail
yang dapat direview kualitasnya
pilihan2x:





grafis (mis flowchart, box diagram)
pseudocode (mis PDL) ... choice of many
Bahasa pemrograman
Tabel Keputusan
Lakukan penelusuran untuk menilai kualitas
These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 6/e and are provided
with permission by R.S. Pressman & Associates, Inc., copyright © 1996, 2001, 2005
20
Pemrograman Terstruktur
untuk desain prosedural
Gunakan sejumlah konstruksi logika
sequence
conditional— if-then-else, select-case
loops— do-while, repeat until
Mengarah pada kode yang mudah dibaca dan diuji
Dapat digunakan untuk membantu koreksi
Penting untuk memperoleh kualitas tinggi
Tapi tidak cukup
These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 6/e and are provided
with permission by R.S. Pressman & Associates, Inc., copyright © 1996, 2001, 2005
21
Desain prosedur terstruktur
add a condition Z,
if true, exit the program
a
x1
b
x2
x3
d
c
e
f
x4
g
x5
These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 6/e and are provided
with permission by R.S. Pressman & Associates, Inc., copyright © 1996, 2001, 2005
22
Tabel Keputusan
Rule s
Condit ions
regular cust omer
1
T
2
3
4
T
T
gold cust omer
F
6
T
silver cust omer
special discount
5
T
F
T
T
T
F
T
Rule s
no discount
apply 8 percent discount
apply 15 percent discount
apply addit ional x percent discount
These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 6/e and are provided
with permission by R.S. Pressman & Associates, Inc., copyright © 1996, 2001, 2005
23
Program Design Language (PDL)
if condition x
then process a;
else process b;
endif
if-then-else
PDL
easy to combine with source code
machine readable, no need for graphics input
graphics can be generated from PDL
enables declaration of data as well as procedure
easier to maintain
These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 6/e and are provided
with permission by R.S. Pressman & Associates, Inc., copyright © 1996, 2001, 2005
24
Why Design Language?
can be a derivative of the HOL of choice
e.g., Ada PDL
machine readable and processable
can be embedded with source code,
therefore easier to maintain
can be represented in great detail, if
designer and coder are different
easy to review
These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 6/e and are provided
with permission by R.S. Pressman & Associates, Inc., copyright © 1996, 2001, 2005
25
Tugas Akhir Semester

Buat Model Analisis dari SRS yang anda buat sebelumnya. Model analisis
berisi diagram :






Buat Model Desain dari model analisis yang anda buat





Use Case Diagram
ERD (pendekatan konvensional)
DFD (pendekatan konvensional)
Activity/Sequence Diagram (Pendekatan OO)
Class Diagram (Pendekatan OO)
Rancangan User Interface
Dinilai dari keterpaduan, kelengkapan, dan alur logika
Dikumpulkan ketika ujian akhir semester
Kelas A disampul mika warna merah
Kelas B disampul mika warna kuning
These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 6/e and are provided
with permission by R.S. Pressman & Associates, Inc., copyright © 1996, 2001, 2005
26