a new reusability metric for object-oriented software
TRANSCRIPT
A New Reusability Metric for Object-Oriented Software
Angggha Satya NugrahaIrene Ully HavsaIndah Kuntum Khairina
JUDITH BARNARD*Department of Computing, The Open University, Milton Keynes, MK7 6AA, UKReceived August 1997
* This paper was written whilst the author was a research associate on the MOODproject at the Department of Computer Science, University of Warwick, Coventry, CV4 7AL, UK
Introduction
•The benefit of reuse:- Reducing project cost - Reducing project time- Improving software quality
Make it more maintainable
Motivation
•How can the developer measure the reusability of their software’s component?
•What guidelines can developers take to ensure they are developing reusable software?
METRIC
Motivation
Why metric?
With a reusability metric, a component can be given a value for reusability that will determine if it reusable or not!
Then, what’s the factors that include in reusability metric?
Discussion on Reusability
Reusability metric
Class metrics
Attribute metricsMethod metrics
Method input parameter metrics
Class MetricsClass Factors Quantifier
Coupling (Foreign classes)
Coupling between object classes (CBO)
Number of methods Number of methods
Number of attributes Number of attributes
Meaningful name Rating 1-5 (1-low, 5-high)
Documentation Number of words in text existing ‘outside’ of the program
Lines of code Number of non-comment source code lines
Comment lines Number of comment lines per line of code
Depth of inheritance Depth of inheritance tree (DIT)
Number of children Number of children (NOC)
Cohesion Lack of cohesion in method (LCOM)
Class variables Number of class variables per line of codeGo to discussion
Attribute MetricsAttribute factors QuantifierMeaningful name Rating 1 to 5 (1-low, 5-
high)
Complexity of data structure
Number of sub-types
Go to discussion
Method MetricsMethod factors Quantifier
Meaningful name Rating 1 to 5 (1-low, 5-high)
Functions performed Number of functions performed
Lines of code Number of non-comment source code lines
Interface parameters Number of input parameters
Calls to foreign classes
Number of calls to foreign classes per line of code
Calls to library classes
Number of calls to library classes per line of code
Robustness Coverage of input parameters satisfied – expressed as fraction between 0 and 1, 0-no coverage, 1-full coverage
Complexity McCabe complexity measure
Instance variables Number of instance variables per line of code
Access Public, protected or private
Go to discussion
Method Input Parameter MetricsMethod input parameter factors
Quantifier
Meaningful name Rating 1 to 5 (1-low, 5-high)
Parameter complexity Number of sub-types
Empirical Work
•This section contains the result of 2 experiments that were carried out
•Steps:1. Making highly reusable code and
highly unreusable code2. Taking metrics from both types of code3. Analyzing the results4. Making some deduction
Experiment 1
Developer A
Developer B
was asked to write the code in a very unreusable manner and would be difficult to reuse elsewhere.
was instructed to write the code in the most reusable manner possible.
Compare both sets of classes (the quantifiers, identified above, were applied to each piece of code and their values compared).
Result Experiment 1 (Class)
Go to conclusion
Result Experiment 1 (Attribute)
Go to conclusion
Result Experiment 1 (Method - A)
Go to conclusion
Result Experiment 1 (Method - B)
Go to conclusion
Result Experiment 1 (Inp.param)
Go to conclusion
Conclusion Experiment 1 (Class)•Some interesting information arises from
these results. Both CBO and LCOM differ widely between the reusable and unreusable code.
CBO
Reusable: low
Unreusable: high
LCOM
Reusable: 0
Unreusable: high
•Other factors do not show any trend between reusable and unreusable code
See the result
Conclusion Experiment 1 (Attribute and Inp.param)
•Show general trend of needing to be simple.
See the result
See the result
Conclusion Experiment 1 (Method)
Reusable Code Unreusable Code
Perform only one function Perform not always one
Has no calls to foreign class Has calls to foreign class
• The remaining factors i.e lines of code, number of input parameter do not provide any useful information.
See the result
See the result
Conclusion Experiment 1
•Experiment 1 was a quick, easy experiment to show where the general trends between reusable and unreusable code lie, in terms of the factors chosen.
•To confirm and enhance any theories that have been arisen, further experiments must be carried out.
Experiment 2
•This experiment involves the analysis of a wide selection of reusable classes taken from well used and accepted programming libraries.
•By taking a significant number of classes in this study (30 classes in this case with over 200 methods), we will show any trends that can be taken literally.
Experiment 2
•From any graphs below, we are looking for factors that give a constant trend for all the classes. Those that vary widely for all the different classes we can assume to be unrelated to reusability.
Experiment 2
The graph related to class metrics:
Experiment 2
Experiment 2
Experiment 2
Experiment 2
The graph related to attribute metrics:
Experiment 2
The graph related to method metrics:
Experiment 2
Experiment 2
Experiment 2
The graph related to input parameter metrics:
Result Experiment 2
•The graphs that show a constant trend for all the classes are related to the following factors: CBO for foreign classes (always zero), class documentation, meaningful names (for class, method, attribute and parameters), DIT (low values – 0 or 1), the number of functions within a method.
Result Experiment 2
•The graphs that do not show a constant trend for all the classes are related to the following factors: number of methods and attributes in a class, number of lines of code and comment lines, LCOM, number of input parameters, method complexity and the number of instance variables.
•The next section discusses these results and puts forward a model and metric of reusability.
New Reusability Metric•Reusability metric for object-oriented software:
New Reusability Metric•A new reusability metric can derive from
the list above.
New Reusability Metric (Formula)•The reusability metric, Reusability, for a
class is defined as:
1 1
c c
m1
p i
a
Reusability
where
MD MN CBO+DIT+1
MN +MC + p NF +NFC
MN PC 1 or 5 if 0
MN AC 1
number of methods in c
cm ca
c c m i a ji j
c
p
i i im i i p kk
p k k p k
ja f j
R R m R a
R
R R
R R p
R
cm
lass
number of attributes in class
number of input parameter of method
, , variable integers
ca
p i
i j k
>10: reusable
<5 : unreusable
Reusability Metric in Ours______________________________
Aplikasi Reusability Metric pada Kode Sumber Tugas 1
Class Diagram
Tool
-drawingPackage: DrawingPackage
+main(String[]): void
DrawingPackage
-screen: Screen-shapes: ShapeList-currentBorder: char-currentFill: char
+Initial(): void+Interact(): void+ApplyDragTool(char, int, int, int, int): void+RedrawAll(): void
Screen
-screenRows: int-screenColumns: int#pixels: int[][]
+DrawPixel(int, int, char): void+ErasePixel(int, int): void+EraseRegion(int, int, int, int): void+EraseAll(): void+Refresh(): void
ShapeList
-maxObject: int-shapes: CShape[]-totalShapes: int
+AddShape(CShape): void+RemoveShape(CShape): void+FirstShapeContaining(int, int): CShape+Select(int, int, int, int): void+UnselectAll(): void+RemoveSelected(): void+SetBorderOfSelected(char): void+SetFillOfSelected(char): void+DrawAll(): void+Reorder(): void
CShape
#border: char#fill: char#selected: boolean#screen: Screen
+Contains(int, int): boolean+Intersects(int, int, int, int): boolean+DrawFill(): void+DrawShape(): void+DrawHandle(): void+OnResizeHandle(int, int): boolean+Resize(int, int): void+Move(int, int): void+Draw(): void+Drag(int, int, int, int): void+SetBorder(char): void+SetFill(char): void+Select(): void+Unselect(): void+Selected(): boolean
CRect
#top: int#left: int#bottom: int#right: int
+Contains(int, int): boolean+Intersects(int, int, int, int): boolean+DrawFill(): void+DrawShape(): void+DrawHandle(): void+OnResizeHandle(int, int): boolean+Resize(int, int): void+Move(int, int): void
CCircle
-centrex: int-centrey: int-radius: int
+Contains(int, int): boolean+Intersects(int, int, int, int): boolean+DrawFill(): void+DrawShape(): void+DrawHandle(): void+OnResizeHandle(int, int): boolean+Resize(int, int): void+Move(int, int): void
CTextBox
-fillText: String
+DrawFill(): void
1
1
1
1
0..*
1
1 0..*
0..*
1
1
1
CBO Coupling Between
Object
DITDepth of Inheritance
MNMeaningful Name
MDMeaningful Description
CLASS
Coupling between Object Classes
Definisi
• Banyaknya kelas lain yang digunakan oleh suatu kelas
Hubungan
• CBO semakin kecil semakin reusable
Perhitungan
• Jumlah kelas lain yang terhubung dari kelas A oleh hubungan asosiasi (non-inheritance)
Acceptable
range
• 0 – 1
Coupling between Object Classes (2)
• Contoh CBO untuk kelas Tool:
CBO = 1
Coupling between Object Classes (3)
• CBO setiap kelas pada aplikasi Character Graphics:Kelas CBO
Tool 1DrawingPackage 3Screen 0ShapeList 1CShape 1CRect 1CCircle 1CTextBox 1
Depth of Inheritance Tree
Definisi
• Jarak maksimum dari suatu simpul ke akar pada inheritance tree
Hubungan
• DIT semakin kecil semakin reusable
Perhitungan
• Jarak maksimum dari kelas A ke root pada inheritance tree
Acceptable
range
• 0 – 1
Depth of Inheritance Tree (2)• DIT setiap kelas pada aplikasi Character Graphics:
Kelas DITTool 0DrawingPackage 0Screen 0ShapeList 0CShape 0CRect 1CCircle 1CTextBox 2
Meaningful Name
Definisi
• Tingkat kejelasan kegunaan class dilihat dari namanya
Hubungan
• MN semakin besar semakin reusable
Perhitungan
• Tergantung asumsi & kebutuhan pihak developer, juga bahasa yang digunakan
Acceptable
range
• 4 – 5
Meaningful Name (2)• Asumsi yang kami gunakan:
▫Dalam Bahasa Inggris : +1▫Berupa kata benda : +1▫ ‘Camel case’ : +1▫Menggambarkan kegunaan class : +2
Meaningful Name (3)• Contoh MN untuk kelas DrawingPackage:
Penilaian : • Dalam Bahasa Inggris : +1• Berupa kata benda : +1• ‘Camel case’ : +1• Menggambarkan kegunaan kelas : +2
MN = 5
Meaningful Name (4)• MN setiap kelas pada aplikasi Character Graphics:
Kelas MNc
Tool 5DrawingPackage 5Screen 5ShapeList 5CShape 5CRect 4CCircle 5CTextBox 5
Meaningful Description
Definisi
• Tingkat kejelasan kegunaan class dilihat dari deskripsi/dokumentasinya.
Hubungan
• MD semakin besar semakin reusable
Perhitungan
• Tergantung asumsi & kebutuhan pihak developer
Acceptable
range
• 4 – 5
Meaningful Description (2)• Asumsi yang kami gunakan:
▫Ada deskripsi kelas : +2▫Ada deskripsi atribut : +1▫Ada deskripsi method : +1▫Ada dokumentasi eksternal : +1
Meaningful Description (3)• Contoh MD untuk kelas CTextBox:
Penilaian : • Ada deskripsi kelas : +2• Ada deskripsi atribut : +1• Ada deskripsi method : +1• Ada dokumentasi eksternal : 0
MD = 4
Meaningful Description (4)• MD setiap kelas pada aplikasi Character Graphics:
Kelas MDc
Tool 0DrawingPackage 3Screen 0ShapeList 1CShape 0CRect 3CCircle 0CTextBox 4
Perhitungan Rc
•Untuk setiap kelas
Kelas Rc
Tool 2.5DrawingPackage 2Screen 5ShapeList 3CShape 2.5CRect 2.33CCircle 1.67CTextBox 2.25
AC Attribute Complexity
MNMeaningful Name
ATTRIBUTE
Attribute Complexity
Definisi
• Kompleksitas struktur data dari atribut
Hubungan
• AC semakin kecil semakin reusable
Perhitungan
• Jumlah sub-tipe dari atribut
Acceptable
range
• 0 – 1
•Contoh AC untuk atribut shapes pada kelas ShapeList:
Attribute Complexity (2)
Perhitungan:Atribut shapes memiliki tipe Cshape,CShape memiliki 3 subtipe, yaitu:• CRect• CCircle• CTextBox
Sehingga untuk shapes, AC = 3
• Class ToolNama Atribut Tipe Atribut AC
drawingPackage DrawingPackage 0
• Class DrawingPackage
Attribute Complexity (3)
Nama Atribut Tipe Atribut AC
screen Screen 0
shapes ShapeList 0
currentBorder char 0
currentFill char 0
• Class ShapeList
Attribute Complexity (4)
Nama Atribut Tipe Atribut AC
maxObjects int 0
shapes Cshape[] 3
totalShapes int 0
• Class ScreenNama Atribut Tipe Atribut AC
screenRows int 0
screenColumns int 0
pixels char[][] 0
Attribute Complexity (5)• Class CShape
Nama Atribut Tipe Atribut AC
border char 0
fill char 0
selected boolean 0
screen Screen 0
• Class CCircleNama Atribut Tipe Atribut AC
centrex int 0
centrey int 0
radius int 0
• Class CRect
Attribute Complexity (6)
Nama Atribut Tipe Atribut AC
top int 0
left int 0
bottom int 0
right int 0
• Class CTextBoxNama Atribut Tipe Atribut AC
fillText String 0
Meaningful Name
Definisi
• Tingkat kejelasan kegunaan atribut dilihat dari namanya
Hubungan
• MN semakin besar semakin reusable
Perhitungan
• Tergantung asumsi & kebutuhan pihak developer, juga bahasa yang digunakan
Acceptable
range
• 4 – 5
• Asumsi yang kami gunakan:▫Dalam Bahasa Inggris : +1▫ ‘Mixed case’ : +1▫Menggambarkan kegunaan atribut: +3
Meaningful Name (2)
Meaningful Name (3)• Contoh MN untuk atribut drawingPackage pada kelas Tool:
Penilaian : • Dalam Bahasa Inggris : +1• ‘Mixed case’ : +1• Menggambarkan kegunaan atribut: +3
MN = 5
• Class ToolNama Atribut MNa
drawingPackage 5
• Class DrawingPackage
Meaningful Name (4)
Nama Atribut MNa
screen 5
shapes 5
currentBorder 5
currentFill 5
• Class ShapeList
Meaningful Name (5)
Nama Atribut MNa
maxObjects 5
shapes 5
totalShapes 5
• Class ScreenNama Atribut MNa
screenRows 5
screenColumns 5
pixels 5
Meaningful Name (6)• Class CShape
Nama Atribut MNa
border 5
fill 5
selected 5
screen 5
• Class CCircleNama Atribut MNa
centrex 5
centrey 5
radius 5
• Class CRect
Meaningful Name (7)
Nama Atribut MNa
top 5
left 5
bottom 5
right 5
• Class CTextBoxNama Atribut MNa
fillText 5
Perhitungan Ra
•Untuk setiap kelas Kelas Ra
Tool 5DrawingPackage 5Screen 5ShapeList 3.75CShape 5CRect 5CCircle 5CTextBox 5
NF Number of Function
Performed
NFCNumber of Calls to
Foreign Classes
MNMeaningful Name
MCMethod Coverage
METHOD
Number of Function Performed
Definisi
• Jumlah fungsi yang dijalankan sebuah method
Hubungan
• NF semakin kecil semakin reusable
Perhitungan
• Jumlah tanda “ ; ” yang bukan pada variabel lokal
Acceptable
range
• 1
Number of Function Performed (2)
•Method RemoveShape pada Class ShapeList
NF = 2
• Class ToolNama Method NF
main 2
• Class DrawingPackage
Nama Method NF
Initial 2
Interact 5
ApplyDragTool 2
RedrawAll 5
• Class Screen
Nama Method NF
DrawPixel 1
ErasePixel 1
EraseRegion 1
EraseAll 1
Refresh 1
Number of Function Performed (3)
• Class ShapeList
Nama Method NF
AddShape 1
RemoveShape 2
FirstShapeContaining
1
Select 1
UnselectAll 1
RemoveSelected 2
SetBorderOfSelected
1
SetFillOfSelected 1
DrawAll 1
Reorder 1
Number of Function Performed (4)
Nama Method NF
Draw 3
Drag 2
SetBorder 1
SetFill 1
Select 1
Unselect 1
Selected 1
Number of Function Performed (5)• Class CShape
Untuk Abstract method langsung di CRect dan CCircle
• Class CRect
Nama Method NF
Contains 1
Intersects 1
DrawFill 1
DrawShape 1
DrawHandle 1
OnResizeHandle 1
Resize 2
Move 4
• Class CCircle
Nama Method NF
Contains 1
Intersects 1
DrawFill 1
DrawShape 1
DrawHandle 1
OnResizeHandle 1
Resize 1
Move 2
Number of Function Performed (6)
• Class CTextBox
Nama Method NF
DrawFill 1
Number of Function Performed (7)
Number of Calls to Foreign Classes
Definisi
• Jumlah pemanggilan method atau constructor dari class lain
Hubungan
• NFC semakin kecil semakin reusable
Perhitungan
• Jumlah distinct class yang method-nya digunakan (tidak termasuk library)
Acceptable
range
• 0 – 1
•Method Select pada Class ShapeList
Number of Calls to Foreign Classes (2)
NFC = 1
• Class Tool
Nama Method NFC
main 1
• Class DrawingPackageNama Method NFC
Initial 0
Interact 1
ApplyDragTool 2
RedrawAll 1
Number of Calls to Foreign Classes (3)
• Class Screen
Nama Method NF
DrawPixel 0
ErasePixel 0
EraseRegion 0
EraseAll 0
Refresh 0
• Class ShapeList
Nama Method NFC
AddShape 0
RemoveShape 0
FirstShapeContaining
1
Select 1
UnselectAll 1
RemoveSelected 1
SetBorderOfSelected
1
SetFillOfSelected 1
DrawAll 1
Reorder 1
Number of Calls to Foreign Classes (4)
Nama Method NFC
Draw 0
Drag 0
SetBorder 0
SetFill 0
Select 0
Unselect 0
Selected 0
Number of Calls to Foreign Classes (5)• Class CShape
Untuk Abstract method langsung di CRect dan CCircle
• Class CRect
Nama Method NFC
Contains 0
Intersects 0
DrawFill 1
DrawShape 1
DrawHandle 1
OnResizeHandle 0
Resize 0
Move 0
• Class CCircle
Nama Method NFC
Contains 0
Intersects 0
DrawFill 1
DrawShape 1
DrawHandle 1
OnResizeHandle 0
Resize 0
Move 0
Number of Calls to Foreign Classes (6)
• Class CTextBox
Nama Method NFC
DrawFill 1
Number of Calls to Foreign Classes (7)
Method Coverage
Definisi
• Tingkat cakupan validasi terhadap nilai – nilai yang digunakan dalam method
Hubungan
• NFC semakin kecil semakin reusable
Perhitungan
• Nilai awal = 1. Jika ada validitas yang tidak di-handle, nilai berkurang x poin (misal 0.1)
Acceptable
range
• 1
•Method Interact pada Class DrawingPackage
Method Coverage (2)
MC = 1 – 4*(0.1) = 0.6
• Class ToolNama Method MC
main 1
• Class DrawingPackageNama Method MC
Initial 1
Interact 0.6
ApplyDragTool 1
RedrawAll 1
• Class Screen
Nama Method MC
DrawPixel 1
ErasePixel 1
EraseRegion 1
EraseAll 1
Refresh 1
Method Coverage (3)
• Class ShapeList
Nama Method MC
AddShape 1
RemoveShape 1
FirstShapeContaining
1
Select 1
UnselectAll 1
RemoveSelected 1
SetBorderOfSelected
1
SetFillOfSelected 1
DrawAll 1
Reorder 1
Method Coverage (4)
Nama Method MC
Draw 1
Drag 1
SetBorder 1
SetFill 1
Select 1
Unselect 1
Selected 1
Method Coverage (5)• Class CShape
Untuk Abstract method langsung di CRect dan CCircle
• Class CRect
Nama Method MC
Contains 1
Intersects 1
DrawFill 1
DrawShape 1
DrawHandle 1
OnResizeHandle 1
Resize 1
Move 1
• Class CCircle
Nama Method MC
Contains 1
Intersects 1
DrawFill 1
DrawShape 1
DrawHandle 1
OnResizeHandle 1
Resize 1
Move 1
Method Coverage (6)
• Class CTextBox
Nama Method MC
DrawFill 1
Method Coverage (7)
Meaningful Name
Definisi
• Tingkat kejelasan kegunaan method dilihat dari namanya
Hubungan
• MN semakin besar semakin reusable
Perhitungan
• Tergantung asumsi & kebutuhan pihak developer, juga bahasa yang digunakan
Acceptable
range
• 4 – 5
• Asumsi yang kami gunakan:▫Dalam Bahasa Inggris : +1▫Berupa kata kerja : +1▫‘Mixed case’ : +1▫Menggambarkan kegunaan method : +2
Meaningful Name (2)
•Method FirstShapeContaining pada Class ShapeList
Meaningful Name (3)
Penilaian : • Dalam Bahasa Inggris : +1• Berupa kata kerja : 0• ‘Mixed case’ : 0• Menggambarkan kegunaan method : +2
MN = 3
• Class ToolNama Method MNm
main 5
• Class DrawingPackageNama Method MNm
Initial 3
Interact 4
ApplyDragTool 4
RedrawAll 4
• Class Screen
Nama Method MNm
DrawPixel 4
ErasePixel 4
EraseRegion 4
EraseAll 4
Refresh 4
Meaningful Name (3)
• Class ShapeList
Nama Method MNm
AddShape 4
RemoveShape 4
FirstShapeContaining
3
Select 4
UnselectAll 4
RemoveSelected 4
SetBorderOfSelected
4
SetFillOfSelected 4
DrawAll 4
Reorder 4
Meaningful Name (4)
• Class CShape
Nama Method MNm
Draw 4
Drag 4
SetBorder 4
SetFill 4
Select 4
Unselect 4
Selected 3
Meaningful Name (5)
Untuk Abstract method langsung di CRect dan CCircle
• Class CRect
Nama Method MNm
Contains 4
Intersects 4
DrawFill 4
DrawShape 4
DrawHandle 4
OnResizeHandle 3
Resize 4
Move 4
• Class CCircle
Nama Method MNm
Contains 4
Intersects 4
DrawFill 4
DrawShape 4
DrawHandle 4
OnResizeHandle 3
Resize 4
Move 4
Meaningful Name (6)
• Class CTextBox
Nama Method MNm
DrawFill 4
Meaningful Name (7)
MNMeaningful Name
PCParameter Complexity
INPUT PARAMETER
Meaningful Name
Definisi
• Tingkat kejelasan kegunaan parameter dilihat dari namanya
Hubungan
• MN semakin besar semakin reusable
Perhitungan
• Tergantung asumsi & kebutuhan pihak developer, juga bahasa yang digunakan
Acceptable
range
• 4 – 5
• Asumsi yang kami gunakan:▫Dalam Bahasa Inggris : +1▫‘Mixed case’ : +1▫Menggambarkan kegunaan parameter : +3
Meaningful Name (2)
•Method Drag pada Class CShape
Meaningful Name (3)
Penilaian : 1. startx
• Dalam Bahasa Inggris : +1• ‘Mixed case’ : +1• Menggambarkan kegunaan parameter: +3• MN = 5
2. starty, endx, dan endy• idem
• Class ToolNama Method
Parameter
MNp
main argv 5
Meaningful Name (4)
• Class DrawingPackageNama Method
Parameter
MNp
ApplyDragTool tool 5
startx 5
starty 5
endx 5
endy 5
• Class ScreenNama Method
Parameter
MNp
DrawPixel x 5
y 5
value 5
ErasePixel x 5
y 5
EraseRegion x1 5
y1 5
x2 5
y2 5
Meaningful Name (5)
• Class ShapeList
Meaningful Name (6)
Nama Method Parameter
MNp
AddShape shape 5
RemoveShape shape 5
FirstShapeContaining
px 5
py 5
Select top 5
left 5
bottom 5
right 5
SetBorderOfSelected
border 5
SetFillOfSelected fill 5
• Class CShapeNama Method Paramete
rMNp
Drag startx 5
starty 5
endx 5
endy 5
SetBorder border 5
SetFill fill 5
Untuk Abstract method langsung di CRect dan CCircle
Meaningful Name (7)
• Class CRect
Meaningful Name (8)
Nama Method
Parameter
MNp
Contains px 5
py 5
Intersects dtop 5
dleft 5
dbottom 5
dright 5
OnResizeHandle
px 5
py 5
Resize dx 5
dy 5
Move dx 5
dy 5
• Class CCircle
Meaningful Name (8)Nama Method
Parameter
MNp
Contains px 5
py 5
Intersects dtop 5
dleft 5
dbottom 5
dright 5
OnResizeHandle
px 5
py 5
Resize dx 5
dy 5
Move dx 5
dy 5
Parameter Complexity
Definisi
• Kompleksitas struktur data dari parameter
Hubungan
• PC semakin kecil semakin reusable
Perhitungan
• Jumlah sub-tipe parameter
Acceptable
range
• 1
•Method AddShape ada ShapeList
Parameter Complexity (2)
Perhitungan:Cshape memiliki 3 subtipe, yaitu:• CRect• CCircle• CTextBox
Sehingga untuk shape, PC = 3
• Class ToolNama Method
Nama Parameter
Tipe Parameter
PC
main argv String[] 0
Parameter Complexity (4)
• Class DrawingPackageNama Method
Nama Parameter
Tipe Parameter
PC
ApplyDragTool tool char 0
startx int 0
starty int 0
endx int 0
endy int 0
• Class ScreenNama Method
Nama Parameter
Tipe Parameter
PC
DrawPixel x int 0
y int 0
value char 0
ErasePixel x int 0
y int 0
EraseRegion x1 int 0
y1 int 0
x2 int 0
y2 int 0
Parameter Complexity (4)
• Class ShapeList
Parameter Complexity (5)
Nama Method Nama Parameter
Tipe Parameter
PC
AddShape shape CShape 3
RemoveShape shape CShape 3
FirstShapeContaining
px int 0
py int 0
Select top int 0
left int 0
bottom int 0
right int 0
SetBorderOfSelected
border char 0
SetFillOfSelected fill char 0
• Class CShapeNama Method
Nama Parameter
Tipe Parameter
PC
Drag startx int 0
starty int 0
endx int 0
endy int 0
SetBorder border char 0
SetFill fill char 0
Untuk Abstract method langsung di CRect dan CCircle
Parameter Complexity (6)
• Class CRect
Parameter Complexity (7)Nama Method
Nama Parameter
Tipe Parameter
PC
Contains px int 0
py int 0
Intersects dtop int 0
dleft int 0
dbottom int 0
dright int 0
OnResizeHandle
px int 0
py int 0
Resize dx int 0
dy int 0
Move dx int 0
dy int 0
• Class CCircle
Parameter Complexity (9)Nama Method
Nama Parameter
Tipe Parameter
PC
Contains px int 0
py int 0
Intersects dtop int 0
dleft int 0
dbottom int 0
dright int 0
OnResizeHandle
px int 0
py int 0
Resize dx int 0
dy int 0
Move dx int 0
dy int 0
Perhitungan Rm
•Untuk setiap kelas Kelas Rm
Tool 3.67DrawingPackage 2.57Screen 10ShapeList 4.72CShape 7.89CRect 6.44CCircle 7.38CTextBox 5
Reusable Class?
Class Tool
•Class Tool is reusable.
Class DrawingPackage
•Class DrawingPackage is reusable.
Class Screen
•Class Screen is reusable.
Class ShapeList
•Class ShapeList is reusable.
Class CShape
•Class CShape is reusable.
Class CRect
•26,66
•Class CRect is reusable.
Class CCircle
•20,67
•Class CCircle is reusable.
Class CTextBox
•5
•Class CTextBox is reusable.
Terima Kasih