4.4 McCabe’s cyclomatic complexity metrics tegies

a 9.4.4 McCabe’s cyclomatic complexity metrics tegies

The cyclomatic complexity metrics developed by McCabe (1976) measures the complexity of a program or module at the same time as it determines the maximum number of independent paths needed to achieve full line cov- erage of the program. The measure is based on graph theory and is thus calculated according to the program characteristics as captured by its pro- gram flow graph.

An independent path is defined with reference to the succession of inde- pendent paths accumulated, that is: “Any path on the program flow graph that includes at least one edge that is not included in any of the former inde- pendent paths”.

To illustrate this definition, let us refer once again to Figure 9.3. A set of independent paths that achieves full line coverage of the program is listed in Table 9.5.

Table 9.4: The Imperial Taxi example – the minimum number of paths No.

The path 1 1-2-3-5-6-8-9-11-12-17

23 1-2-4-5-7-8-10-11-13-14-15-17 24 1-2-4-5-7-8-10-11-13-14-16-17

Table 9.5: The ITS example – the set of independent paths to achieve full coverage

Path The path Edges added by the path Number of edges no.

added by the path 1 1-2-3-5-6-8-9-11-12-17

1-2, 2-3, 3-5, 5-6, 6-8, 8-9, 9

9-11, 11-12, 12-17

2 1-2-3-5-6-8-9-11-13-14-15-17 11-13, 13-14, 14-15, 15-17 4 3 1-2-3-5-6-8-9-11-13-14-16-17

2 4 1-2-4-5-7-8-10-11-13-14-15-17

14-16, 16-17

2-4, 4-5, 5-7, 7-8, 8-10, 10-11 6

As mentioned above, the cyclomatic complexity metric V(G) also deter- 195 mines the maximum number of independent paths that can be indicated in

the program flow graph.

The cyclomatic complexity metric (V(G)) is expressed in three different ways, all of which are based on the program flow graph:

White bo

(1) V(G) = R (2) V(G) = E – N + 2

tes ting

(3) V(G) = P + 1

In these equations R is the number of regions in the program flow graph. Any enclosed area in the graph is considered a region. In addition the area around the graph not enclosed by it is counted as one additional region. E is the number of edges in the program flow graph, N is the number of nodes in the program flow graph, and P is the number of decisions contained in the graph, represented by nodes having more than one leaving edge.

Example Applying the above to the ITS taximeter module example described above, we can obtain the values of the above parameters from Figure 9.3. We find that R = 6, E = 21, N = 17, and P = 5. Substituting these values into the met- rics formulae we obtain:

(1) V(G) = R = 6 (2) V(G) = E – N + 2 = 21 – 17 + 2 = 6 (3) V(G) = P + 1 = 5 + 1 = 6

The resulting metrics calculations indicate that the maximum number of independent paths in the example is six. One realization of a maximal set of six independent paths is shown in Table 9.6.

Several empirical studies of the relationships between the cyclomatic complexity metrics and quality and testability characteristics have been car-

Table 9.6: The ITS example – the maximum set of independent paths Path The path

Number of edges no.

Edges added by the path

added by the path 1 1-2-3-5-6-8-9-11-12-17

1-2, 2-3, 3-5, 5-6, 5-8, 8-9,

9-11, 11-12, 12-17

2 1-2-4-5-6-8-9-11-12-17

2 3 1-2-3-5-7-8-9-11-12-17

2-4, 4-5

2 4 1-2-3-5-6-8-10-11-12-17

5-7, 7-8

2 5 1-2-3-5-6-8-9-11-13-14-15-17 11-13, 13-14, 14-15, 15-17

8-10, 10-11

4 6 1-2-3-5-6-8-9-11-13-14-16-17 14-16, 16-17

196 ried out over the years. Some of the findings are summarized by Jones (1996) as follows: “Empirical studies reveal that programs with cyclomat-

9 ic complexities of less than 5 are generally considered simple and easy to Softw

understand. Cyclomatic complexities of 10 or less are considered not too difficult; if 20 or more, the complexity is perceived as high. When the

are tes

McCabe value exceeds 50, the software for practical purposes becomes untestable.” Other publications report no confirmation of the relationship between the cyclomatic complexity metrics and the quality of the software,

ting – str

or that the relationships found have not been supported statistically (Fenton, 1995, pp. 279–281).

Dokumen yang terkait

ALOKASI WAKTU KYAI DALAM MENINGKATKAN KUALITAS SUMBER DAYA MANUSIA DI YAYASAN KYAI SYARIFUDDIN LUMAJANG (Working Hours of Moeslem Foundation Head In Improving The Quality Of Human Resources In Kyai Syarifuddin Foundation Lumajang)

1 46 7

Anal isi s L e ve l Pe r tanyaan p ad a S oal Ce r ita d alam B u k u T e k s M at e m at ik a Pe n u n jang S MK Pr ogr a m Keahl ian T e k n ologi , Kese h at an , d an Pe r tani an Kelas X T e r b itan E r lan gga B e r d asarkan T ak s on om i S OL O

2 99 16

Analisis Pengaruh Banking Service Quality Dimensions (BSQ) Terhadap Kepuasan Nasabah PT. Bank Jatim Cabang Jember (Analysis Effect of Banking Service Quality Dimensions (BSQ) Toward Bank Customer Satisfaction on PT. Bank Jatim Branch Jember )

2 40 6

Mekanisme pengajuan klaim produk individu asuransi jiwa pada PT. MAA Life Assurance Syariah

6 85 87

Laporan Realisasi Anggaran N e r a c a C

0 11 4

PENGARUH KOSENTRASI SARI KUNYIT PUTIH (Curcuma zediaria) TERHADAP KUALITAS TELUR ASIN DITINJAU DARI AKTIVITAS ANTIOKSIDAN, TOTAL FENOL, KADAR PROTEIN DAN KADAR GARAM The Addition of White Turmeric (Curcuma zedoaria) Concentrated Base on Quality Antioxidan

1 1 8

Studi Pengaruh Kondisi Penyetelan Nosebar pada Mesin Kupas terhadap Tekanan Kempa dan Kualitas Potong Venir Study on the Influences of Nosebar Setting of a Peeler on the Compressive Forces and Cutting Quality of Veneer

0 0 7

Physical and Chemical Quality of Silage Organic Market Waste with Lamtoro Leaf Flour (Leucaena leucacephala) as Alternative Feed

0 0 5

J a n g k a S o r o n g M ik r o m e te r S e k r u p

0 0 36

Pengembangan Desain Produk Teh Gelas Dengan Menggunakan Metode Quality Function Deployment Untuk Meningkatkan Penjualan Di CV. Tirta Indo Megah

0 0 5