A New Reusability Metric for Object-Oriented Software

1,072 views
1,004 views

Published on

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,072
On SlideShare
0
From Embeds
0
Number of Embeds
213
Actions
Shares
0
Downloads
30
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide
  • Semakinkecil CBO suatukelas semakinindependenkelastersebut  semakinmudahkelastersebut di-reusepadaaplikasi lain.Menggunakan method/atributkelas lain
  • Semakinkecil DIT suatukelas semakindalamkelastersebutpadahierarki  semakinbanyakmethod yang di-inherit olehkelastersebut semakinkompleksuntukmemprediksibehaviornya semakinsulitkelastersebut di-reusepadaaplikasi lain.Deeper trees greater design complexity
  • Hanya yangtipeatributnyaCshapesaja
  • Aturanmenghitung : (tapijadinyabanyak….)Jumlahtanda “ ; ” yang bukanpadavariabel temporalnbuahSystem.outdianggapsebagai 1 fungsi “menulisoutput”nbuah System.in dianggapsebagai 1 fungsi “membacainput”Instansiasi / membuatobjekdihitungsebagaifungsinbuah return dihitungsebagai 1 fungsiDalam if-else dihitung 1n buahpemanggilan method ygsamadianggap 1
  • Aturanmenghitung : (tapijadinyabanyak….)Jumlahtanda “ ; ” yang bukanpadavariabel temporalnbuahSystem.outdianggapsebagai 1 fungsi “menulisoutput”nbuah System.in dianggapsebagai 1 fungsi “membacainput”Instansiasi / membuatobjekdihitungsebagaifungsinbuah return dihitungsebagai 1 fungsiDalam if-else dihitung 1n buahpemanggilan method ygsamadianggap 1
  • Yang lain nilai full
  • Aturanmenghitung : (tapijadinyabanyak….)Jumlahtanda “ ; ” yang bukanpadavariabel temporalnbuahSystem.outdianggapsebagai 1 fungsi “menulisoutput”nbuah System.in dianggapsebagai 1 fungsi “membacainput”Instansiasi / membuatobjekdihitungsebagaifungsinbuah return dihitungsebagai 1 fungsiDalam if-else dihitung 1n buahpemanggilan method ygsamadianggap 1
  • Yang lain nilai full
  • Aturanmenghitung : (tapijadinyabanyak….)Jumlahtanda “ ; ” yang bukanpadavariabel temporalnbuahSystem.outdianggapsebagai 1 fungsi “menulisoutput”nbuah System.in dianggapsebagai 1 fungsi “membacainput”Instansiasi / membuatobjekdihitungsebagaifungsinbuah return dihitungsebagai 1 fungsiDalam if-else dihitung 1n buahpemanggilan method ygsamadianggap 1
  • Yang lain nilai full
  • Yang lain nilai full
  • Sub-tipe : sub-class
  • Hanya yangparameternyaCshapesaja
  • Yang lain nilai full
  • Yang lain nilai full
  • A New Reusability Metric for Object-Oriented Software

    1. 1. A New Reusability Metric for Object-Oriented Software JUDITH BARNARD* Department of Computing, The Open University, Milton Keynes, MK7 6AA, UK Received August 1997 Angggha Satya Nugraha Irene Ully Havsa Indah Kuntum Khairina* This paper was written whilst the author was a research associate on the MOODproject at the Department of Computer Science, University ofWarwick, Coventry, CV4 7AL, UK
    2. 2. Introduction• The benefit of reuse: - Reducing project cost - Reducing project time - Improving software quality Make it more maintainable
    3. 3. 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
    4. 4. MotivationWhy metric?With a reusability metric, a component can begiven a value for reusability that willdetermine if it reusable or not!Then, what’s the factors that include in reusabilitymetric?
    5. 5. Discussion on Reusability Class metrics Attribute metricsReusability metric Method metrics Method input parameter metrics
    6. 6. Class MetricsClass Factors QuantifierCoupling (Foreign classes) Coupling between object classes (CBO)Number of methods Number of methodsNumber of attributes Number of attributesMeaningful name Rating 1-5 (1-low, 5-high)Documentation Number of words in text existing ‘outside’ of the programLines of code Number of non-comment source code linesComment lines Number of comment lines per line of codeDepth 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 code Go to discussion
    7. 7. Attribute MetricsAttribute factors QuantifierMeaningful name Rating 1 to 5 (1-low, 5-high)Complexity of data structure Number of sub-types Go to discussion
    8. 8. Method MetricsMethod factors QuantifierMeaningful name Rating 1 to 5 (1-low, 5-high)Functions performed Number of functions performedLines of code Number of non-comment source code linesInterface parameters Number of input parametersCalls to foreign classes Number of calls to foreign classes per line of codeCalls to library classes Number of calls to library classes per line of codeRobustness Coverage of input parameters satisfied – expressed as fraction between 0 and 1, 0-no coverage, 1-full coverageComplexity McCabe complexity measureInstance variables Number of instance variables per line of codeAccess Public, protected or private Go to discussion
    9. 9. Method Input Parameter MetricsMethod input parameter factors QuantifierMeaningful name Rating 1 to 5 (1-low, 5-high)Parameter complexity Number of sub-types
    10. 10. Empirical Work• This section contains the result of 2 experiments that were carried out• Steps: 1. Making highly reusable code and highly unreusable code 2. Taking metrics from both types of code 3. Analyzing the results 4. Making some deduction
    11. 11. Experiment 1Developer A was asked to write the code in a very unreusable manner and would be difficult to reuse elsewhere.Developer B was instructed to write the code in the most reusable manner possible.Compare both sets of classes (thequantifiers, identified above, were applied to eachpiece of code and their values compared).
    12. 12. Result Experiment 1 (Class) Go to conclusion
    13. 13. Result Experiment 1 (Attribute) Go to conclusion
    14. 14. Result Experiment 1 (Method - A) Go to conclusion
    15. 15. Result Experiment 1 (Method - B) Go to conclusion
    16. 16. Result Experiment 1 (Inp.param) Go to conclusion
    17. 17. Conclusion Experiment 1 (Class)• Some interesting information arises from these results. Both CBO and LCOM differ widely between the reusable and unreusable code. Reusable: low Reusable: 0CBO LCOM Unreusable: high Unreusable: high• Other factors do not show any trend between reusable and unreusable code See the result
    18. 18. Conclusion Experiment 1 (Attributeand Inp.param)• Show general trend of needing to be simple. See the result See the result
    19. 19. Conclusion Experiment 1 (Method) Reusable Code Unreusable CodePerform only one function Perform not always oneHas 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
    20. 20. 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.
    21. 21. 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.
    22. 22. 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.
    23. 23. Experiment 2The graph related to class metrics:
    24. 24. Experiment 2
    25. 25. Experiment 2
    26. 26. Experiment 2
    27. 27. Experiment 2The graph related to attribute metrics:
    28. 28. Experiment 2The graph related to method metrics:
    29. 29. Experiment 2
    30. 30. Experiment 2
    31. 31. Experiment 2The graph related to input parameter metrics:
    32. 32. 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.
    33. 33. 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.
    34. 34. New Reusability Metric• Reusability metric for object-oriented software:
    35. 35. New Reusability Metric• A new reusability metric can derive from the list above.
    36. 36. New Reusability Metric (Formula) • The reusability metric, Reusability, for a class is defined as: >10: reusable cm caReusability R Rc m R c a m i a j i 1 j 1whereRc MD c MN c CBO+DIT+1 <5 : unreusable pRm i MN m i +MCi + Rp k p NFi +NFCi k 1Rp k MN p PCi k 1 or Rp k 5 if p 0Ra f MN a j AC j 1cm number of methods in classca number of attributes in classp number of input parameter of method ii, j , k variable integers
    37. 37. Reusability Metric in Ours______________________________ Aplikasi Reusability Metric pada Kode Sumber Tugas 1
    38. 38. Class Diagram CShape #border: char #fill: char #selected: boolean CRect #screen: Screen #top: int Screen +Contains(int, int): boolean #left: int -screenRows: int +Intersects(int, int, int, int): boolean #bottom: int -screenColumns: int +DrawFill(): void #right: int #pixels: int[][] 0..* +DrawShape(): void 1 +Contains(int, int): boolean +DrawHandle(): void +Intersects(int, int, int, int): boolean +DrawPixel(int, int, char): void +OnResizeHandle(int, int): boolean +DrawFill(): void +ErasePixel(int, int): void +Resize(int, int): void +DrawShape(): void +EraseRegion(int, int, int, int): void +Move(int, int): void +DrawHandle(): void +EraseAll(): void +Draw(): void +OnResizeHandle(int, int): boolean +Refresh(): void +Drag(int, int, int, int): void +Resize(int, int): void 0..* +SetBorder(char): void +Move(int, int): void 1 +SetFill(char): void +Select(): void +Unselect(): void 1 1 +Selected(): boolean DrawingPackage CTextBox 0..* -screen: Screen -shapes: ShapeList -fillText: String -currentBorder: char 1 +DrawFill(): void -currentFill: char ShapeList +Initial(): void +Interact(): void -maxObject: int CCircle +ApplyDragTool(char, int, int, int, int): void -shapes: CShape[] +RedrawAll(): void 1 -totalShapes: int -centrex: int 1 -centrey: int +AddShape(CShape): void -radius: int 1 +RemoveShape(CShape): void +FirstShapeContaining(int, int): CShape +Contains(int, int): boolean +Select(int, int, int, int): void +Intersects(int, int, int, int): boolean +UnselectAll(): void +DrawFill(): void 1 +RemoveSelected(): void +DrawShape(): void Tool +SetBorderOfSelected(char): void +DrawHandle(): void +SetFillOfSelected(char): void +OnResizeHandle(int, int): boolean -drawingPackage: DrawingPackage +DrawAll(): void +Resize(int, int): void +main(String[]): void +Reorder(): void +Move(int, int): void
    39. 39. CBO DITCoupling Between Depth of Inheritance Object CLASS MN MD MeaningfulMeaningful Name Description
    40. 40. Coupling between Object Classes • Banyaknya kelas lain yang digunakan oleh suatu Definisi kelas • CBO semakin kecil  semakin reusable Hubungan • Jumlah kelas lain yang terhubung dari kelas A olehPerhitungan hubungan asosiasi (non-inheritance)Acceptable •0–1 range
    41. 41. Coupling between Object Classes (2)• Contoh CBO untuk kelas Tool: CBO = 1
    42. 42. Coupling between Object Classes (3)• CBO setiap kelas pada aplikasi Character Graphics: Kelas CBO Tool 1 DrawingPackage 3 Screen 0 ShapeList 1 CShape 1 CRect 1 CCircle 1 CTextBox 1
    43. 43. Depth of Inheritance Tree • Jarak maksimum dari suatu simpul ke akar pada Definisi inheritance tree • DIT semakin kecil  semakin reusableHubungan • Jarak maksimum dari kelas A ke root padaPerhitungan inheritance treeAcceptable •0–1 range
    44. 44. Depth of Inheritance Tree (2)• DIT setiap kelas pada aplikasi Character Graphics: Kelas DIT Tool 0 DrawingPackage 0 Screen 0 ShapeList 0 CShape 0 CRect 1 CCircle 1 CTextBox 2
    45. 45. Meaningful Name • Tingkat kejelasan kegunaan class dilihat dari Definisi namanya • MN semakin besar  semakin reusableHubungan • Tergantung asumsi & kebutuhan pihakPerhitungan developer, juga bahasa yang digunakanAcceptable •4–5 range
    46. 46. Meaningful Name (2)• Asumsi yang kami gunakan: ▫ Dalam Bahasa Inggris : +1 ▫ Berupa kata benda : +1 ▫ ‘Camel case’ : +1 ▫ Menggambarkan kegunaan class : +2
    47. 47. 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
    48. 48. Meaningful Name (4)• MN setiap kelas pada aplikasi Character Graphics: Kelas MNc Tool 5 DrawingPackage 5 Screen 5 ShapeList 5 CShape 5 CRect 4 CCircle 5 CTextBox 5
    49. 49. Meaningful Description • Tingkat kejelasan kegunaan class dilihat dari Definisi deskripsi/dokumentasinya. • MD semakin besar  semakin reusableHubungan • Tergantung asumsi & kebutuhan pihak developerPerhitunganAcceptable •4–5 range
    50. 50. Meaningful Description (2)• Asumsi yang kami gunakan: ▫ Ada deskripsi kelas : +2 ▫ Ada deskripsi atribut : +1 ▫ Ada deskripsi method : +1 ▫ Ada dokumentasi eksternal : +1
    51. 51. 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
    52. 52. Meaningful Description (4)• MD setiap kelas pada aplikasi Character Graphics: Kelas MDc Tool 0 DrawingPackage 3 Screen 0 ShapeList 1 CShape 0 CRect 3 CCircle 0 CTextBox 4
    53. 53. Perhitungan Rc• Kelas Rc Tool 2.5 DrawingPackage 2 Screen 5 ShapeList 3 CShape 2.5 CRect 2.33 CCircle 1.67 CTextBox 2.25
    54. 54. AC MNAttribute Complexity Meaningful Name ATTRIBUTE
    55. 55. Attribute Complexity • Kompleksitas struktur data dari atribut Definisi • AC semakin kecil  semakin reusableHubungan • Jumlah sub-tipe dari atributPerhitunganAcceptable •0–1 range
    56. 56. Attribute Complexity (2)• Contoh AC untuk atribut shapes pada kelas ShapeList: Perhitungan: Atribut shapes memiliki tipe Cshape, CShape memiliki 3 subtipe, yaitu: • CRect • CCircle • CTextBox Sehingga untuk shapes, AC = 3
    57. 57. Attribute Complexity (3)• Class Tool Nama Atribut Tipe Atribut AC drawingPackage DrawingPackage 0• Class DrawingPackage Nama Atribut Tipe Atribut AC screen Screen 0 shapes ShapeList 0 currentBorder char 0 currentFill char 0
    58. 58. Attribute Complexity (4)• Class Screen Nama Atribut Tipe Atribut AC screenRows int 0 screenColumns int 0 pixels char[][] 0• Class ShapeList Nama Atribut Tipe Atribut AC maxObjects int 0 shapes Cshape[] 3 totalShapes int 0
    59. 59. Attribute Complexity (5)• Class CShape Nama Atribut Tipe Atribut AC border char 0 fill char 0 selected boolean 0 screen Screen 0• Class CCircle Nama Atribut Tipe Atribut AC centrex int 0 centrey int 0 radius int 0
    60. 60. Attribute Complexity (6)• Class CRect Nama Atribut Tipe Atribut AC top int 0 left int 0 bottom int 0 right int 0• Class CTextBox Nama Atribut Tipe Atribut AC fillText String 0
    61. 61. Meaningful Name • Tingkat kejelasan kegunaan atribut dilihat dari Definisi namanya • MN semakin besar  semakin reusableHubungan • Tergantung asumsi & kebutuhan pihak developer,Perhitungan juga bahasa yang digunakanAcceptable •4–5 range
    62. 62. Meaningful Name (2)• Asumsi yang kami gunakan: ▫ Dalam Bahasa Inggris : +1 ▫ ‘Mixed case’ : +1 ▫ Menggambarkan kegunaan atribut: +3
    63. 63. 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
    64. 64. Meaningful Name (4)• Class Tool Nama Atribut MNa drawingPackage 5• Class DrawingPackage Nama Atribut MNa screen 5 shapes 5 currentBorder 5 currentFill 5
    65. 65. Meaningful Name (5)• Class Screen Nama Atribut MNa screenRows 5 screenColumns 5 pixels 5• Class ShapeList Nama Atribut MNa maxObjects 5 shapes 5 totalShapes 5
    66. 66. Meaningful Name (6)• Class CShape Nama Atribut MNa border 5 fill 5 selected 5 screen 5• Class CCircle Nama Atribut MNa centrex 5 centrey 5 radius 5
    67. 67. Meaningful Name (7)• Class CRect Nama Atribut MNa top 5 left 5 bottom 5 right 5• Class CTextBox Nama Atribut MNa fillText 5
    68. 68. Perhitungan Ra• Kelas Ra Tool 5 DrawingPackage 5 Screen 5 ShapeList 3.75 CShape 5 CRect 5 CCircle 5 CTextBox 5
    69. 69. NF NFCNumber of Function Number of Calls to Performed Foreign Classes METHOD MN MCMeaningful Name Method Coverage
    70. 70. Number of Function Performed • Jumlah fungsi yang dijalankan sebuah method Definisi • NF semakin kecil  semakin reusableHubungan • Jumlah tanda “ ; ” yang bukan pada variabel lokalPerhitunganAcceptable •1 range
    71. 71. Number of Function Performed (2)• Method RemoveShape pada Class ShapeList NF = 2
    72. 72. Number of Function Performed (3)• Class Tool • Class Screen Nama Method NF Nama Method NF main 2 DrawPixel 1 ErasePixel 1• Class DrawingPackage EraseRegion 1 Nama Method NF EraseAll 1 Initial 2 Refresh 1 Interact 5 ApplyDragTool 2 RedrawAll 5
    73. 73. Number of Function Performed (4)• 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
    74. 74. Number of Function Performed (5)• Class CShape Nama Method NF Draw 3 Drag 2 SetBorder 1 SetFill 1 Select 1 Unselect 1 Selected 1 Untuk Abstract method langsung di CRect dan CCircle
    75. 75. Number of Function Performed (6)• Class CRect • Class CCircle Nama Method NF Nama Method NF Contains 1 Contains 1 Intersects 1 Intersects 1 DrawFill 1 DrawFill 1 DrawShape 1 DrawShape 1 DrawHandle 1 DrawHandle 1 OnResizeHandle 1 OnResizeHandle 1 Resize 2 Resize 1 Move 4 Move 2
    76. 76. Number of Function Performed (7)• Class CTextBox Nama Method NF DrawFill 1
    77. 77. Number of Calls to Foreign Classes • Jumlah pemanggilan method atau constructor dari Definisi class lain • NFC semakin kecil  semakin reusable Hubungan • Jumlah distinct class yang method-nya digunakanPerhitungan (tidak termasuk library)Acceptable •0–1 range
    78. 78. Number of Calls to Foreign Classes (2)• Method Select pada Class ShapeList NFC = 1
    79. 79. Number of Calls to Foreign Classes (3)• Class Tool • Class Screen Nama Method NFC Nama Method NF main 1 DrawPixel 0 ErasePixel 0• Class DrawingPackage EraseRegion 0 Nama Method NFC EraseAll 0 Initial 0 Refresh 0 Interact 1 ApplyDragTool 2 RedrawAll 1
    80. 80. Number of Calls to Foreign Classes (4)• 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
    81. 81. Number of Calls to Foreign Classes (5)• Class CShape Nama Method NFC Draw 0 Drag 0 SetBorder 0 SetFill 0 Select 0 Unselect 0 Selected 0 Untuk Abstract method langsung di CRect dan CCircle
    82. 82. Number of Calls to Foreign Classes (6)• Class CRect • Class CCircle Nama Method NFC Nama Method NFC Contains 0 Contains 0 Intersects 0 Intersects 0 DrawFill 1 DrawFill 1 DrawShape 1 DrawShape 1 DrawHandle 1 DrawHandle 1 OnResizeHandle 0 OnResizeHandle 0 Resize 0 Resize 0 Move 0 Move 0
    83. 83. Number of Calls to Foreign Classes (7)• Class CTextBox Nama Method NFC DrawFill 1
    84. 84. Method Coverage • Tingkat cakupan validasi terhadap nilai – nilai yang Definisi digunakan dalam method • NFC semakin kecil  semakin reusableHubungan • Nilai awal = 1. Jika ada validitas yang tidak di-Perhitungan handle, nilai berkurang x poin (misal 0.1)Acceptable •1 range
    85. 85. Method Coverage (2)• Method Interact pada Class DrawingPackage MC = 1 – 4*(0.1) = 0.6
    86. 86. Method Coverage (3)• Class Tool • Class Screen Nama Method MC Nama Method MC main 1 DrawPixel 1 ErasePixel 1• Class DrawingPackage EraseRegion 1 Nama Method MC EraseAll 1 Initial 1 Refresh 1 Interact 0.6 ApplyDragTool 1 RedrawAll 1
    87. 87. Method Coverage (4)• 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
    88. 88. Method Coverage (5)• Class CShape Nama Method MC Draw 1 Drag 1 SetBorder 1 SetFill 1 Select 1 Unselect 1 Selected 1 Untuk Abstract method langsung di CRect dan CCircle
    89. 89. Method Coverage (6)• Class CRect • Class CCircle Nama Method MC Nama Method MC Contains 1 Contains 1 Intersects 1 Intersects 1 DrawFill 1 DrawFill 1 DrawShape 1 DrawShape 1 DrawHandle 1 DrawHandle 1 OnResizeHandle 1 OnResizeHandle 1 Resize 1 Resize 1 Move 1 Move 1
    90. 90. Method Coverage (7)• Class CTextBox Nama Method MC DrawFill 1
    91. 91. Meaningful Name • Tingkat kejelasan kegunaan method dilihat dari Definisi namanya • MN semakin besar  semakin reusableHubungan • Tergantung asumsi & kebutuhan pihakPerhitungan developer, juga bahasa yang digunakanAcceptable •4–5 range
    92. 92. Meaningful Name (2)• Asumsi yang kami gunakan: ▫ Dalam Bahasa Inggris : +1 ▫ Berupa kata kerja : +1 ▫ ‘Mixed case’ : +1 ▫ Menggambarkan kegunaan method : +2
    93. 93. Meaningful Name (3)• Method FirstShapeContaining pada Class ShapeList Penilaian : • Dalam Bahasa Inggris : +1 • Berupa kata kerja : 0 • ‘Mixed case’ : 0 • Menggambarkan kegunaan method : +2 MN = 3
    94. 94. Meaningful Name (3)• Class Tool • Class Screen Nama Method MNm Nama Method MNm main 5 DrawPixel 4 ErasePixel 4• Class DrawingPackage EraseRegion 4 Nama Method MNm EraseAll 4 Initial 3 Refresh 4 Interact 4 ApplyDragTool 4 RedrawAll 4
    95. 95. Meaningful Name (4)• 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
    96. 96. Meaningful Name (5)• Class CShape Nama Method MNm Draw 4 Drag 4 SetBorder 4 SetFill 4 Select 4 Unselect 4 Selected 3 Untuk Abstract method langsung di CRect dan CCircle
    97. 97. Meaningful Name (6)• Class CRect • Class CCircle Nama Method MNm Nama Method MNm Contains 4 Contains 4 Intersects 4 Intersects 4 DrawFill 4 DrawFill 4 DrawShape 4 DrawShape 4 DrawHandle 4 DrawHandle 4 OnResizeHandle 3 OnResizeHandle 3 Resize 4 Resize 4 Move 4 Move 4
    98. 98. Meaningful Name (7)• Class CTextBox Nama Method MNm DrawFill 4
    99. 99. MN PC ParameterMeaningful Name Complexity INPUT PARAMETER
    100. 100. Meaningful Name • Tingkat kejelasan kegunaan parameter dilihat dari Definisi namanya • MN semakin besar  semakin reusableHubungan • Tergantung asumsi & kebutuhan pihak developer,Perhitungan juga bahasa yang digunakanAcceptable •4–5 range
    101. 101. Meaningful Name (2)• Asumsi yang kami gunakan: ▫ Dalam Bahasa Inggris : +1 ▫ ‘Mixed case’ : +1 ▫ Menggambarkan kegunaan parameter : +3
    102. 102. Meaningful Name (3)• Method Drag pada Class CShape Penilaian : 1. startx • Dalam Bahasa Inggris : +1 • ‘Mixed case’ : +1 • Menggambarkan kegunaan parameter: +3 • MN = 5 2. starty, endx, dan endy • idem
    103. 103. Meaningful Name (4)• Class Tool Nama Method Parameter MNp main argv 5• Class DrawingPackage Nama Method Parameter MNp ApplyDragTool tool 5 startx 5 starty 5 endx 5 endy 5
    104. 104. Meaningful Name (5)• Class Screen Nama Method Parameter MNp DrawPixel x 5 y 5 value 5 ErasePixel x 5 y 5 EraseRegion x1 5 y1 5 x2 5 y2 5
    105. 105. Meaningful Name (6)• Class ShapeList 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
    106. 106. Meaningful Name (7)• Class CShape Nama Method Parameter MNp Drag startx 5 starty 5 endx 5 endy 5 SetBorder border 5 SetFill fill 5 Untuk Abstract method langsung di CRect dan CCircle
    107. 107. Meaningful Name (8)• Class CRect 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
    108. 108. Meaningful Name (8)• Class CCircle 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
    109. 109. Parameter Complexity • Kompleksitas struktur data dari parameter Definisi • PC semakin kecil  semakin reusableHubungan • Jumlah sub-tipe parameterPerhitunganAcceptable •1 range
    110. 110. Parameter Complexity (2)• Method AddShape ada ShapeList Perhitungan: Cshape memiliki 3 subtipe, yaitu: • CRect • CCircle • CTextBox Sehingga untuk shape, PC = 3
    111. 111. Parameter Complexity (4)• Class Tool Nama Method Nama Parameter Tipe Parameter PC main argv String[] 0• Class DrawingPackage Nama Method Nama Parameter Tipe Parameter PC ApplyDragTool tool char 0 startx int 0 starty int 0 endx int 0 endy int 0
    112. 112. Parameter Complexity (4)• Class Screen Nama 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
    113. 113. Parameter Complexity (5)• Class ShapeList 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
    114. 114. Parameter Complexity (6)• Class CShape Nama 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
    115. 115. Parameter Complexity (7)• Class CRect 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
    116. 116. Parameter Complexity (9)• Class CCircle 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
    117. 117. Perhitungan Rm• Kelas Rm Tool 3.67 DrawingPackage 2.57 Screen 10 ShapeList 4.72 CShape 7.89 CRect 6.44 CCircle 7.38 CTextBox 5
    118. 118. Reusable Class?
    119. 119. Class Tool•
    120. 120. Class DrawingPackage•
    121. 121. Class Screen•
    122. 122. Class ShapeList•
    123. 123. Class CShape•
    124. 124. Class CRect•
    125. 125. Class CCircle•
    126. 126. Class CTextBox•
    127. 127. Terima Kasih 

    ×