thesis - Faculty of Information and Communication Technologies ...
thesis - Faculty of Information and Communication Technologies ...
thesis - Faculty of Information and Communication Technologies ...
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Chapter D. Metric Extraction Illustration<br />
1 /∗∗ Total counts for a subset <strong>of</strong> metrics are included in the header<br />
2 ∗ LIC (Load Count) = 15, SIC ( Store Count) = 2, NOM (Number <strong>of</strong> Methods) = 2<br />
3 ∗ NOB (Number <strong>of</strong> Branches ) = 6, TCC (Type Construction Count) = 1<br />
4 ∗ MCC (Method Call Count) = 3, THC (Throw Count) = 1, EXC ( Exception Count) = 1<br />
5 ∗ ODC (Out Degree Count) = 4 ( String , Exception , PrintStream , System. out )<br />
6 ∗ NOF (Number <strong>of</strong> Fields ) = 3, IOC ( Increment Operation Count) = 3<br />
7 ∗ LVC ( Local Variable Count) = 3<br />
8 ∗/<br />
9 public class MetricCountExample<br />
10 {<br />
11 private boolean bField ; // un−initialised field<br />
12<br />
13 // 2 LOADS: this , constant integer<br />
14 private int index = 5; // 1 STORE<br />
15<br />
16 // 2 LOADS: this , constant string<br />
17 private String str = " Hello World ! " ; // 1 STORE<br />
18<br />
19 // Default Constructor<br />
20 // 1 LOAD ( this ) , 1 METHOD CALL ( constructor <strong>of</strong> super class java . lang . Object )<br />
21<br />
22 public void methodX ( String msg ) throws Exception<br />
23 {<br />
24 int a = 5; // 1 LOAD constant <strong>of</strong> 5, 1 STORE into local variable a<br />
25 methodY ( ) ; // 1 INTERNAL method call , 1 LOAD: this object<br />
26<br />
27 // BRANCH count = 2, one for the i f <strong>and</strong> another for &&<br />
28 // 4 LOADS: a , this , index , <strong>and</strong> bField<br />
29 i f ( ( a > index ) && ( bField == f a l s e ) ) return ;<br />
30<br />
31 // BRANCH count = 2, default is not counted , 1 per each case<br />
32 switch ( index ) // 2 LOADS: this , index<br />
33 {<br />
34 case 0: a++; // INCREMENT operation<br />
35 case 1: a−−; // INCREMENT operation with −1<br />
36 default : a−−; // INCREMENT operation with −1<br />
37 }<br />
38<br />
39 // BRANCH COUNT = 1, TYPE Construction Count = 1 (new Exception )<br />
40 // THROW Count = 1, 2 LOADS: args array , constant value 3<br />
41 i f ( msg == null ) throw new Exception ( " Something odd" ) ;<br />
42 }<br />
43<br />
44 public void methodY ( )<br />
45 {<br />
46 // 2 LOAD constants , 1 STORE, 1 INCREMENT OPERATION, 1 BRANCH ( for loop condition<br />
)<br />
47 for ( int j=0; j