a new reusability metric for object-oriented software

127
A New Reusability Metric for Object-Oriented Software Angggha Satya Nugraha Irene Ully Havsa Indah Kuntum Khairina JUDITH BARNARD* Department of Computing, The Open University, Milton Keynes, MK7 6AA, UK Received 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

Upload: newreusabilitymetric

Post on 13-May-2015

776 views

Category:

Technology


3 download

TRANSCRIPT

Page 1: A New Reusability Metric for Object-Oriented Software

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

Page 2: A New Reusability Metric for Object-Oriented Software

Introduction

•The benefit of reuse:- Reducing project cost - Reducing project time- Improving software quality

Make it more maintainable

Page 3: A New Reusability Metric for Object-Oriented Software

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

Page 4: A New Reusability Metric for Object-Oriented Software

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?

Page 5: A New Reusability Metric for Object-Oriented Software

Discussion on Reusability

Reusability metric

Class metrics

Attribute metricsMethod metrics

Method input parameter metrics

Page 6: A New Reusability Metric for Object-Oriented Software

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

Page 7: A New Reusability Metric for Object-Oriented Software

Attribute MetricsAttribute factors QuantifierMeaningful name Rating 1 to 5 (1-low, 5-

high)

Complexity of data structure

Number of sub-types

Go to discussion

Page 8: A New Reusability Metric for Object-Oriented Software

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

Page 9: A New Reusability Metric for Object-Oriented Software

Method Input Parameter MetricsMethod input parameter factors

Quantifier

Meaningful name Rating 1 to 5 (1-low, 5-high)

Parameter complexity Number of sub-types

Page 10: A New Reusability Metric for Object-Oriented Software

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

Page 11: A New Reusability Metric for Object-Oriented Software

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).

Page 12: A New Reusability Metric for Object-Oriented Software

Result Experiment 1 (Class)

Go to conclusion

Page 13: A New Reusability Metric for Object-Oriented Software

Result Experiment 1 (Attribute)

Go to conclusion

Page 14: A New Reusability Metric for Object-Oriented Software

Result Experiment 1 (Method - A)

Go to conclusion

Page 15: A New Reusability Metric for Object-Oriented Software

Result Experiment 1 (Method - B)

Go to conclusion

Page 16: A New Reusability Metric for Object-Oriented Software

Result Experiment 1 (Inp.param)

Go to conclusion

Page 17: A New Reusability Metric for Object-Oriented Software

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

Page 18: A New Reusability Metric for Object-Oriented Software

Conclusion Experiment 1 (Attribute and Inp.param)

•Show general trend of needing to be simple.

See the result

See the result

Page 19: A New Reusability Metric for Object-Oriented Software

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

Page 20: A New Reusability Metric for Object-Oriented Software

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.

Page 21: A New Reusability Metric for Object-Oriented Software

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.

Page 22: A New Reusability Metric for Object-Oriented Software

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.

Page 23: A New Reusability Metric for Object-Oriented Software

Experiment 2

The graph related to class metrics:

Page 24: A New Reusability Metric for Object-Oriented Software

Experiment 2

Page 25: A New Reusability Metric for Object-Oriented Software

Experiment 2

Page 26: A New Reusability Metric for Object-Oriented Software

Experiment 2

Page 27: A New Reusability Metric for Object-Oriented Software

Experiment 2

The graph related to attribute metrics:

Page 28: A New Reusability Metric for Object-Oriented Software

Experiment 2

The graph related to method metrics:

Page 29: A New Reusability Metric for Object-Oriented Software

Experiment 2

Page 30: A New Reusability Metric for Object-Oriented Software

Experiment 2

Page 31: A New Reusability Metric for Object-Oriented Software

Experiment 2

The graph related to input parameter metrics:

Page 32: A New Reusability Metric for Object-Oriented Software

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.

Page 33: A New Reusability Metric for Object-Oriented Software

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.

Page 34: A New Reusability Metric for Object-Oriented Software

New Reusability Metric•Reusability metric for object-oriented software:

Page 35: A New Reusability Metric for Object-Oriented Software

New Reusability Metric•A new reusability metric can derive from

the list above.

Page 36: A New Reusability Metric for Object-Oriented Software

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

Page 37: A New Reusability Metric for Object-Oriented Software

Reusability Metric in Ours______________________________

Aplikasi Reusability Metric pada Kode Sumber Tugas 1

Page 38: A New Reusability Metric for Object-Oriented Software

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

Page 39: A New Reusability Metric for Object-Oriented Software

CBO Coupling Between

Object

DITDepth of Inheritance

MNMeaningful Name

MDMeaningful Description

CLASS

Page 40: A New Reusability Metric for Object-Oriented Software

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

Page 41: A New Reusability Metric for Object-Oriented Software

Coupling between Object Classes (2)

• Contoh CBO untuk kelas Tool:

CBO = 1

Page 42: A New Reusability Metric for Object-Oriented Software

Coupling between Object Classes (3)

• CBO setiap kelas pada aplikasi Character Graphics:Kelas CBO

Tool 1DrawingPackage 3Screen 0ShapeList 1CShape 1CRect 1CCircle 1CTextBox 1

Page 43: A New Reusability Metric for Object-Oriented Software

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

Page 44: A New Reusability Metric for Object-Oriented Software

Depth of Inheritance Tree (2)• DIT setiap kelas pada aplikasi Character Graphics:

Kelas DITTool 0DrawingPackage 0Screen 0ShapeList 0CShape 0CRect 1CCircle 1CTextBox 2

Page 45: A New Reusability Metric for Object-Oriented Software

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

Page 46: A New Reusability Metric for Object-Oriented Software

Meaningful Name (2)• Asumsi yang kami gunakan:

▫Dalam Bahasa Inggris : +1▫Berupa kata benda : +1▫ ‘Camel case’ : +1▫Menggambarkan kegunaan class : +2

Page 47: A New Reusability Metric for Object-Oriented Software

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

Page 48: A New Reusability Metric for Object-Oriented Software

Meaningful Name (4)• MN setiap kelas pada aplikasi Character Graphics:

Kelas MNc

Tool 5DrawingPackage 5Screen 5ShapeList 5CShape 5CRect 4CCircle 5CTextBox 5

Page 49: A New Reusability Metric for Object-Oriented Software

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

Page 50: A New Reusability Metric for Object-Oriented Software

Meaningful Description (2)• Asumsi yang kami gunakan:

▫Ada deskripsi kelas : +2▫Ada deskripsi atribut : +1▫Ada deskripsi method : +1▫Ada dokumentasi eksternal : +1

Page 51: A New Reusability Metric for Object-Oriented Software

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

Page 52: A New Reusability Metric for Object-Oriented Software

Meaningful Description (4)• MD setiap kelas pada aplikasi Character Graphics:

Kelas MDc

Tool 0DrawingPackage 3Screen 0ShapeList 1CShape 0CRect 3CCircle 0CTextBox 4

Page 53: A New Reusability Metric for Object-Oriented Software

Perhitungan Rc

•Untuk setiap kelas

Kelas Rc

Tool 2.5DrawingPackage 2Screen 5ShapeList 3CShape 2.5CRect 2.33CCircle 1.67CTextBox 2.25

Page 54: A New Reusability Metric for Object-Oriented Software

AC Attribute Complexity

MNMeaningful Name

ATTRIBUTE

Page 55: A New Reusability Metric for Object-Oriented Software

Attribute Complexity

Definisi

• Kompleksitas struktur data dari atribut

Hubungan

• AC semakin kecil semakin reusable

Perhitungan

• Jumlah sub-tipe dari atribut

Acceptable

range

• 0 – 1

Page 56: A New Reusability Metric for Object-Oriented Software

•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

Page 57: A New Reusability Metric for Object-Oriented Software

• 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

Page 58: A New Reusability Metric for Object-Oriented Software

• 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

Page 59: A New Reusability Metric for Object-Oriented Software

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

Page 60: A New Reusability Metric for Object-Oriented Software

• 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

Page 61: A New Reusability Metric for Object-Oriented Software

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

Page 62: A New Reusability Metric for Object-Oriented Software

• Asumsi yang kami gunakan:▫Dalam Bahasa Inggris : +1▫ ‘Mixed case’ : +1▫Menggambarkan kegunaan atribut: +3

Meaningful Name (2)

Page 63: A New Reusability Metric for Object-Oriented Software

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

Page 64: A New Reusability Metric for Object-Oriented Software

• Class ToolNama Atribut MNa

drawingPackage 5

• Class DrawingPackage

Meaningful Name (4)

Nama Atribut MNa

screen 5

shapes 5

currentBorder 5

currentFill 5

Page 65: A New Reusability Metric for Object-Oriented Software

• Class ShapeList

Meaningful Name (5)

Nama Atribut MNa

maxObjects 5

shapes 5

totalShapes 5

• Class ScreenNama Atribut MNa

screenRows 5

screenColumns 5

pixels 5

Page 66: A New Reusability Metric for Object-Oriented Software

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

Page 67: A New Reusability Metric for Object-Oriented Software

• Class CRect

Meaningful Name (7)

Nama Atribut MNa

top 5

left 5

bottom 5

right 5

• Class CTextBoxNama Atribut MNa

fillText 5

Page 68: A New Reusability Metric for Object-Oriented Software

Perhitungan Ra

•Untuk setiap kelas Kelas Ra

Tool 5DrawingPackage 5Screen 5ShapeList 3.75CShape 5CRect 5CCircle 5CTextBox 5

Page 69: A New Reusability Metric for Object-Oriented Software

NF Number of Function

Performed

NFCNumber of Calls to

Foreign Classes

MNMeaningful Name

MCMethod Coverage

METHOD

Page 70: A New Reusability Metric for Object-Oriented Software

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

Page 71: A New Reusability Metric for Object-Oriented Software

Number of Function Performed (2)

•Method RemoveShape pada Class ShapeList

NF = 2

Page 72: A New Reusability Metric for Object-Oriented Software

• 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)

Page 73: A New Reusability Metric for Object-Oriented Software

• 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)

Page 74: A New Reusability Metric for Object-Oriented Software

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

Page 75: A New Reusability Metric for Object-Oriented Software

• 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)

Page 76: A New Reusability Metric for Object-Oriented Software

• Class CTextBox

Nama Method NF

DrawFill 1

Number of Function Performed (7)

Page 77: A New Reusability Metric for Object-Oriented Software

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

Page 78: A New Reusability Metric for Object-Oriented Software

•Method Select pada Class ShapeList

Number of Calls to Foreign Classes (2)

NFC = 1

Page 79: A New Reusability Metric for Object-Oriented Software

• 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

Page 80: A New Reusability Metric for Object-Oriented Software

• 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)

Page 81: A New Reusability Metric for Object-Oriented Software

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

Page 82: A New Reusability Metric for Object-Oriented Software

• 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)

Page 83: A New Reusability Metric for Object-Oriented Software

• Class CTextBox

Nama Method NFC

DrawFill 1

Number of Calls to Foreign Classes (7)

Page 84: A New Reusability Metric for Object-Oriented Software

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

Page 85: A New Reusability Metric for Object-Oriented Software

•Method Interact pada Class DrawingPackage

Method Coverage (2)

MC = 1 – 4*(0.1) = 0.6

Page 86: A New Reusability Metric for Object-Oriented Software

• 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)

Page 87: A New Reusability Metric for Object-Oriented Software

• 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)

Page 88: A New Reusability Metric for Object-Oriented Software

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

Page 89: A New Reusability Metric for Object-Oriented Software

• 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)

Page 90: A New Reusability Metric for Object-Oriented Software

• Class CTextBox

Nama Method MC

DrawFill 1

Method Coverage (7)

Page 91: A New Reusability Metric for Object-Oriented Software

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

Page 92: A New Reusability Metric for Object-Oriented Software

• Asumsi yang kami gunakan:▫Dalam Bahasa Inggris : +1▫Berupa kata kerja : +1▫‘Mixed case’ : +1▫Menggambarkan kegunaan method : +2

Meaningful Name (2)

Page 93: A New Reusability Metric for Object-Oriented Software

•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

Page 94: A New Reusability Metric for Object-Oriented Software

• 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)

Page 95: A New Reusability Metric for Object-Oriented Software

• 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)

Page 96: A New Reusability Metric for Object-Oriented Software

• 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

Page 97: A New Reusability Metric for Object-Oriented Software

• 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)

Page 98: A New Reusability Metric for Object-Oriented Software

• Class CTextBox

Nama Method MNm

DrawFill 4

Meaningful Name (7)

Page 99: A New Reusability Metric for Object-Oriented Software

MNMeaningful Name

PCParameter Complexity

INPUT PARAMETER

Page 100: A New Reusability Metric for Object-Oriented Software

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

Page 101: A New Reusability Metric for Object-Oriented Software

• Asumsi yang kami gunakan:▫Dalam Bahasa Inggris : +1▫‘Mixed case’ : +1▫Menggambarkan kegunaan parameter : +3

Meaningful Name (2)

Page 102: A New Reusability Metric for Object-Oriented Software

•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

Page 103: A New Reusability Metric for Object-Oriented Software

• 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

Page 104: A New Reusability Metric for Object-Oriented Software

• 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)

Page 105: A New Reusability Metric for Object-Oriented Software

• 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

Page 106: A New Reusability Metric for Object-Oriented Software

• 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)

Page 107: A New Reusability Metric for Object-Oriented Software

• 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

Page 108: A New Reusability Metric for Object-Oriented Software

• 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

Page 109: A New Reusability Metric for Object-Oriented Software

Parameter Complexity

Definisi

• Kompleksitas struktur data dari parameter

Hubungan

• PC semakin kecil semakin reusable

Perhitungan

• Jumlah sub-tipe parameter

Acceptable

range

• 1

Page 110: A New Reusability Metric for Object-Oriented Software

•Method AddShape ada ShapeList

Parameter Complexity (2)

Perhitungan:Cshape memiliki 3 subtipe, yaitu:• CRect• CCircle• CTextBox

Sehingga untuk shape, PC = 3

Page 111: A New Reusability Metric for Object-Oriented Software

• 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

Page 112: A New Reusability Metric for Object-Oriented Software

• 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)

Page 113: A New Reusability Metric for Object-Oriented Software

• 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

Page 114: A New Reusability Metric for Object-Oriented Software

• 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)

Page 115: A New Reusability Metric for Object-Oriented Software

• 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

Page 116: A New Reusability Metric for Object-Oriented Software

• 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

Page 117: A New Reusability Metric for Object-Oriented Software

Perhitungan Rm

•Untuk setiap kelas Kelas Rm

Tool 3.67DrawingPackage 2.57Screen 10ShapeList 4.72CShape 7.89CRect 6.44CCircle 7.38CTextBox 5

Page 118: A New Reusability Metric for Object-Oriented Software

Reusable Class?

Page 119: A New Reusability Metric for Object-Oriented Software

Class Tool

•Class Tool is reusable.

Page 120: A New Reusability Metric for Object-Oriented Software

Class DrawingPackage

•Class DrawingPackage is reusable.

Page 121: A New Reusability Metric for Object-Oriented Software

Class Screen

•Class Screen is reusable.

Page 122: A New Reusability Metric for Object-Oriented Software

Class ShapeList

•Class ShapeList is reusable.

Page 123: A New Reusability Metric for Object-Oriented Software

Class CShape

•Class CShape is reusable.

Page 124: A New Reusability Metric for Object-Oriented Software

Class CRect

•26,66

•Class CRect is reusable.

Page 125: A New Reusability Metric for Object-Oriented Software

Class CCircle

•20,67

•Class CCircle is reusable.

Page 126: A New Reusability Metric for Object-Oriented Software

Class CTextBox

•5

•Class CTextBox is reusable.

Page 127: A New Reusability Metric for Object-Oriented Software

Terima Kasih