Sie sind auf Seite 1von 6

VOL. 2, NO.

10, October 2011

ISSN 2079-8407

Journal of Emerging Trends in Computing and Information Sciences


2009-2011 CIS Journal. All rights reserved.

http://www.cisjournal.org

A Novel Metric For Measuring The Readability of Software Source Code


Bajeh, A. O.
Department of Computer Science, University of Ilorin, Ilorin, Nigeria bajeh_amos@yahoo.com, bajehamos@unilorin.edu.ng, bajehamos@ieee.org

ABSTRACT
Software metrics gives developers and their client and users of Software information about the quality of their Software products. They are employed in taking decisions at various levels of Software Life Cycle (SLC). This paper presents a novel metric for measuring the readability of Software Source Code (SC). Maintenance changes (addition, removal or modification), though, are initially carried out on the Software design artifacts, they are eventually performed on the Software SC as the finished product. Thus this metric is relevant in estimating the readability quality of SCs. The metric is ratio scaled and size independent. Results showed that the metric objectively measures the readability of SC. Keywords: Software Metrics, Readability, Source Code, Maintainability, Measurement

1. INTRODUCTION
One of the highly debated aspects of Software Engineering (SE) in the literatures is Software Metrics. Unlike in other engineering discipline, SE has not yet attains a level where there are standard and globally acceptable measurement metrics and models [1], [2]. To carry out the development/maintenance activities of Software products, understanding the Software designs and finished products is critical. Activities such as maintenance and testing require understanding the Software artifacts (design and code). Software Quality Models (SQM) reflects understandability in their list of quality characteristics/attributes. The ISO 9126 [3] enlists Analyzability as one of the quality characteristics and intuitively it engages (, to a large extent) understandability. Likewise, changeability and testability engages understandability. Other SQMs directly or indirectly enlist understandability as one of their quality characteristics or attributes; quality models such as McCalls, Boehms, and Dromeys, etc [4], [5], [6].

linear regression model for the understandability of class hierarchy tree. Sheldon et al [10], [11] also developed a model for the understandability of class inheritance tree. Khairuddin et al [12] proposed a maintainability attribute model which enlists readability as one of the factors affecting maintainability. They discussed how internal and external documentations enhance readability; though did not state how readability could be measured or estimated. This paper presents a metric which measures readability of Software SCs. The metric is based on the physical layout of the SC. Finding a way to objectively measure this metric will depict the understandability quality of Software SCs. Though this metric can only be collected from SCs, it will find relevance in determining the readability of SC since maintenance changes (addition, removal, modification) will eventually be carried out on the SC and this makes it(SC) imperative to be understood. A mumbled SC will be more difficult to understand than a well laid out SC. Also Software maintainers can employ this metric in measuring the readability of SCs and use this information in estimating the difficulty that may be involved in maintaining SC during making a contract deal with clients that outsource for Software Maintainer.

For a Software artifact to be understandable it must be readable. Software SC, as an artifact must be readable to aid its understandability which directly or indirectly enhances analyzability, changeability and other quality characteristics/attributes. This paper presents a 3. THE PROPOSED METRIC novel metric for the measurement of the readability of Software Source Codes (SCs). This metric can serve as a This work employs the Goal Question Metric (GQM) subcharacteristic or attribute to other quality characteristics approach [13], [14], [15] to Software metrication in such as analyzability, modifiability/changeability, etc. devising the proposed metric. Figure 1 illustrates the GQM paradigm [].

2. RELATED WORK
In literature several Software quality metrics and models have been proposed and also theoretically and empirically validated [3], [4], [7], [8]. Design level metrics have been proposed for understandability. Rizvi et al [9] proposed a

492

VOL. 2, NO. 10, October 2011

ISSN 2079-8407

Journal of Emerging Trends in Computing and Information Sciences


2009-2011 CIS Journal. All rights reserved.

http://www.cisjournal.org

Goal 1

Goal 2

Question1

Question 2

Question 3

Question 4

segment B follows the same pattern. Thus if this pattern of indentation can be identified uniquely for every SC line, a count of the number of lines that follow (or do not follow) this pattern can be measured.

(iii) One of the properties of a good Software metric is non-size metrics should be system size independent [16]. Ratio scale Figure 1: GQM Paradigm is considered as the best among the measurement scales because it is most precise in measurement [17]. To answer The approach involves setting Goal(s) that clearly question (iii), the proposed metric is computed as follows: emphasis the purpose(s) for which metrics are to be designed; asking Question(s) that need to be answered in order to achieve the set Goal(s), i.e. formulating Question(s) in such a way that proffering solutions to them leads to achieving the intended Goal(s); and then, selecting or devising Metric(s) that provide the information needed is the Number of Properly Indented lines of SC where to answer the formulated Question(s). is the Number of Expected Indentations and is and The application of this approach to devise the and the Layout readability the proposed metric. proposed metric is as follows: are direct measures.
Metric 1 Metric 2 Metric 3 Metric 4 Metric 5

Alternatively, this metric can be computed as Goal: Device a metric that objectively measure the readability of SC layout. Questions: (i) What is the form of SC layouts enhances/decreases readability? that where is the number of Improperly Indented Lines of SCs and it is also a direct measure. (ii) What can be measured from the SC that reflects the pattern of the SC layout? When the value of is close to 1 it shows a better layout compared to a value close to 0. Obviously a value of 1 depicts a proper and complete indentation of SC because the number of properly indented SC lines will be equal to the expected indentation. And a value of 0 depicts a completely mumbled SC because the numerator will be 0 implying that non of the SC lines is properly indented. Figure 4 below depicts this metrics range of values. follows:

(iii) Can the measure be based on the ratio scale and SC size independent? Metric: To device the metric to measure the readability of SCs, answers were proffered to the above questions: (i) Figures 2(a) and 2(b) show two different layouts of a SC that carries out the same function; i.e. they are syntactically and semantically the same but different in layout/indentation. It is obvious that the layout in figure 2(b) is easier to read than that of 2(a). Thus, properly indented SCs are more readable than those that are not.

0
decreasing layout readability

0.5

1
increasing layout readability

Figure 3: (ii) Statements that are components of other compound statements/modules should be indented to reflect their positions. In figure 2(b) the segment labeled A is the body of module main. In other words statements in segment A are effective by the virtue of the main module. Similarly segment C is the body of the while iterative statement; also

Measurement Scale

4.METRIC MEASUREMENT
To demonstrate the collection of the direct measures and the computation of the proposed metric from Software SCs, the SCs in figure 2(a) and 2(b) are used. For clarity purpose these SC are duplicated in figures 4(a) and 4(b)

493

VOL. 2, NO. 10, October 2011

ISSN 2079-8407

Journal of Emerging Trends in Computing and Information Sciences


2009-2011 CIS Journal. All rights reserved.

http://www.cisjournal.org

respectively with arrows to identify indented lines. The 6.CONCLUSION AND RECOMMENDATION direct measures were collected from the SCs in figure 4 by A ratio scale based metric for measuring the readability of counting the number of arrows in the figures and they are SC layouts was devised. The metric is size independent and as follows: intuitively interpretable. As the metric value tends towards 1, it depicts that the SC is more readable. The converse is The expected Indentation is measured from figure 4(b) also true: as the metric value tends towards 0, it depicts that (which is properly and completely indented) by counting the SC is less readable. all the arrows: This metric can be employed by Software Maintainers that take outsourced Software for maintenance in determining the readability of SCs of Software during = 31 taking up a deal with their clients. The metric can serve as attribute or subcharacteristic of other higher level quality characteristics such as analyzability in the hierarchical Measurement of the readability of the SC in figure 4(a): SQMs. (Number of arrows in figure 4(a))

REFERENCES
[1] P. Bourque, S. Wolf, R. Dupris, A. Sellami and A. Abran, Lack of Consensus on Measurement in Software Engineering, Accessed: 15th January, 2011, Available: http://www.gelog.etsml.ca/publications/pdf/836.pdf [2] T. S. Frederick, J. Kshamta and C. Hong, Metrics for Maintainability of Class Inheritance Hierarchies, Journal of Software Maintenance and Evolution: Research and Practice 14, pp. 1-4, 2002. [3] ISO/JTC/ 1/SC 7, ISO/IEC 9126 Software Engineering-Product Quality (Part 1-4), 2001 [4] B. Kitchenlam and S. L. Pfleeger, Software Quality: The Elusive Target, IEEE Software, vol. 13 No. 1, pp. 12-21, 1996. Thus, the SC in figure 4(b) (with a measure of 1) has a better readability than the SC in figure 4(a) (with a measure of 0.29). [5] R. S. Pressman, Software Engineering: A Practitioners Approach, Ed. 6th (Intl Ed.), McGrawHill, 2005. [6] N. Bawane and C.V. Srikrishna, A Novel Method for Quantitative Assessment of Software Quality, Intl Journal of Computer Science and Security, Vol. 3 Issue 6, pp. 508-517. [7] K. K. Aggarwal,., Measurement of Software Maintainability using a Fuzzy Model, Journal of Computer Science 1(4), ISSN 1549-3636, pp. 538542, 2005.

Measurement of the readability of the SC in figure 4(b):

5.FUTURE WORK
This paper presents one of the results of an ongoing research in Software Metrics. The work further involves the automation of the process of collecting this measurement from Software SCs. Afterwards an extensive empirical study of the applicability and correlation of this metric with SC readability and understandability will be carried out.

494

VOL. 2, NO. 10, October 2011

ISSN 2079-8407

Journal of Emerging Trends in Computing and Information Sciences


2009-2011 CIS Journal. All rights reserved.

http://www.cisjournal.org

[8] I. Heitlager, T. Kuipers and J. Visser, A Practical Model for Measuring Maintainability, In 6th Intl Conference on the Quality of Information and Communication Technology (QUATIC 2007), IEEE Computer Society, pp. 30-39, 2007. [9] S.W.A. Rizvi and R. A. Khan, Maintainability Estimation Model for Object Oriented Software in Design Phase (MEMOOD), Journal of Computing, vol. 2 Issue 4, 2010. [10] F. T. Sheldon, K. Jerath and H. Chung, Metrics for Maintainability of Class Inheritance Hierarchies, Journal of Software Maintenance and Evolution: Research and Practice, 14:1-14, 2002. [11] K. Rajnish, A. K. Choudhary and A. M. Agrawal, Inheritance Metrics for Object-Oriented Design, Intl Journal of Computer Science and Information Technology (IJCSIT), vol. 2 no. 6, 2010. [12] K. Hashim and E. Key, A Software Maintainability Attributes Model, Malaysian Journal of Computer Science, vol. 9 No. 2, pp. 92-97, 1996.

[13] V. Basili, L. Briand, S. Condon, Y. Kim, W. L. Melo abd Jon D. Vallet, Understanding and Predicting the Process of Software Maintenance Releases, In Proceedings of ICSE 18, pp. 464-474, 1996. [14] V. R. Basili, Software Modeling and Measurement: The Goal Question Metric Paradigm, Computer Science Technical Report Series CS-TR-2956 (UMIACS-TR-92-96), University of Maryland, College Park, MD, USA, 1992. [15] V. Basili, G. Caldeira and H. D. Rombach, Encyclopedia of Software Engineering, chapter The Goal Question Metric Approach, Wiley, 1994. [16] Fernando Brito e Abreu and R. Carapuca, ObjectOriented Software Engineering: Measuring and Controlling the Development Process, In Proceedings of 4th Int. Conference on Software Quality, McLean, VA, USA, 1994. [17] C. R. Kothari, Research Methodology: Methods and Techniques, 2nd Revised Edition. Delhi, India: New Age Intl (P) Ltd Publishers, 2008, pp. 69-82.

(a)

#include<stdio.h> #include<string.h> #include<alloc.h> main() {structrekord{charname[60];intnumb; inti=0; FirstPtr=(structrekord*)malloc(sizeof(structrecord)); printf(\nEntername);scanf(%s,FirstPtr>name); printf(\nEnterinteger);scanf(%d,FirstPtr>numb); ptr=FirstPtr;i=1; while(i<3) {ptr>next=(structrecord*)malloc(sizeof(structrecord)); Ptr=ptr>next; printf(\nEntername);scanf(%*[\n]%s,ptr>name); printf(\nEnterinterger);scanf(%d,&ptr>numb);i++; } Ptr>next=NULL; Ptr=FirstPtr; for(ptr=FirstPtr;ptr!=NULL;ptr=ptr>next)printf(nName:%sNumber:%d,ptr>name,ptr>numb); printf(\nPressreturnkeytocontinue);getch();return0;} structrekord*next; }*FirstPtr,*ptr;

495

VOL. 2, NO. 10, October 2011

ISSN 2079-8407

Journal of Emerging Trends in Computing and Information Sciences


2009-2011 CIS Journal. All rights reserved.

http://www.cisjournal.org

(b)

#include<stdio.h> #include<string.h> #include<alloc.h> main() { structrekord{charname[60]; intnumb;B inti=0; FirstPtr=(structrekord*)malloc(sizeof(structrecord)); printf(\nEntername); scanf(%s,FirstPtr>name); printf(\nEnterinteger); scanf(%d,FirstPtr>numb); ptr=FirstPtr;i=1; while(i<3) { ptr>next=(structrecord*)malloc(sizeof(structrecord)); Ptr=ptr>next; printf(\nEntername);scanf(%*[\n]%s,ptr>name); printf(\nEnterinterger);scanf(%d,&ptr>numb);i++; } Ptr>next=NULL; Ptr=FirstPtr; for(ptr=FirstPtr;ptr!=NULL;ptr=ptr>next)printf(nName:%sNumber:%d,ptr>name,ptr>numb); printf(\nPressreturnkeytocontinue); Figure 2: Source Code Layout getch(); return0; } structrekord*next; }*FirstPtr,*ptr;

Figure 2: Source Code Layout

496

VOL. 2, NO. 10, October 2011

ISSN 2079-8407

Journal of Emerging Trends in Computing and Information Sciences


2009-2011 CIS Journal. All rights reserved.

http://www.cisjournal.org

(a)

#include <stdio.h> #include <string.h> #include <alloc.h> main() {struct rekord{ char name[60]; int numb; struct rekord *next; }*FirstPtr, *ptr; int i=0; FirstPtr= (struct rekord *) malloc(sizeof(struct record)); printf(\nEnter name ); scanf(%s,FirstPtr->name); printf(\nEnter integer ); scanf(%d,FirstPtr->numb); ptr= FirstPtr; i=1; while(i<3) {ptr->next=(struct record *) malloc(sizeof(struct record)); Ptr=ptr->next; printf(\nEnter name ); scanf(%*[\n]%s,ptr->name); printf(\nEnter interger ); scanf(%d,&ptr->numb);i++; } Ptr->next=NULL;Ptr=FirstPtr; for(ptr=FirstPtr;ptr!=NULL;ptr=ptr->next) printf(nName: %s Number: %d, ptr->name, ptr->numb); printf(\nPress return key to continue); getch(); return 0; }

(b)

#include <stdio.h> #include <string.h> #include <alloc.h> main() { struct rekord{ char name[60]; int numb; struct rekord *next; }*FirstPtr, *ptr; int i=0; FirstPtr= (struct rekord *) malloc(sizeof(struct record)); printf(\nEnter name ); scanf(%s,FirstPtr->name); printf(\nEnter integer ); scanf(%d,FirstPtr->numb); ptr= FirstPtr; i=1; while(i<3) { ptr->next=(struct record *) malloc(sizeof(struct record)); Ptr=ptr->next; printf(\nEnter name ); scanf(%*[\n]%s,ptr->name); printf(\nEnter interger ); scanf(%d,&ptr->numb);i++; } Ptr->next=NULL; Ptr=FirstPtr; for(ptr=FirstPtr;ptr!=NULL;ptr=ptr->next) printf(nName: %s Number: %d, ptr->name, ptr->numb); printf(\nPress return key to continue); getch(); return 0; }

Figure 4: SCs showing Indented Lines

497

Das könnte Ihnen auch gefallen