Professional Documents
Culture Documents
Applying Halstead Software Science On Different Programming Languages For Analyzing Software Complexity
Applying Halstead Software Science On Different Programming Languages For Analyzing Software Complexity
Applying Halstead Software Science On Different Programming Languages For Analyzing Software Complexity
Abstract—In software development, it is crucial that each and parameters. The objective of this article is to analyze software
every unit of effort must be measurable. If it is not measurable, complexity in different programming languages by applying
S oftware engineers must try to make it measurable. S oftware Halstead software science. This article is structured as section 2
metrics are any unit of software product measurement. S oftware includes the introduction of Halstead Software Science. Section
metrics have emerged as an important mechanism to find a 3 comprises related work while Section 4 comprises programs
significant estimation of software products. This estimation to check whether a number is a Palindrome or not in five
usually includes complexity, effort, size of the code, time different programming languages as, C, C++, Java, PHP, and
consumption, etc. By applying Halstead software science, we can python. Section 5 includes software science calculations on
analyze the different complexity factors of a program. This
various parameters that collectively define software
software science can lead us to effective technical as well as
managerial decisions. In this paper, Halstead metrics of the
complexity. Section 6 comprises the results on the basis of the
program for checking for palindrome number in five different analysis performed in section 5. Section 7 & 8 comprise the
programming languages have been taken and analysis has been conclusion and future work of this article respectively.
presented.
II. HALST EAD SOFT WARE SCIENCE
Keywords—software metrics; Halstead metrics; complexity;
estimation Maurice Howard Halstead was the first-ever researcher
who wrote the mathematical formulation of software metrics
[1]. His incredible research is widely used as an alternative to
I. INT RODUCT ION
counting the Lines of Code (LOC) as a measurement for
A software development incorporates different phases program size and software complexity. Lines of Code is
during the software development life cycle. Throughout the purely programming language-dependent and may vary the
development processes, organizations tried to fulfill the moment that convert our code in any other programming
requirements of the client(s) as well as to provide specific and language. In such a case, Halstead software science provides a
numerous characteristics [6] [7]. These characteristics can be prudent approach to calculate software size and complexity
used to identify the overall complexity of any subsystem or
precisely [13] [14]. To calculate software metrics, Halstead
even a software product. Usually, software complexity can be
classified the source code as either operator &/or operands
construed in terms of execution time, the effort required to
execute program(s) along with memory required to execute the [15]. The tokens applied in this measurement are as below
computations [5].This complexity is one of the decisive [10] [11]:
components of the software metrics. It has been observed that
software metrics are correlated to the measurement of the The Halstead software science measures are-
software product. K1 = number of unique operators,
Software metrics is a measurement-based approach that is K2 = number of unique operands,
being applied essentially to improve the overall process and
efficiency of the software products [8]. Maurice Howard N1 = total number of operators &
Halstead in 1977 introduced s uch a software metric which is
N2 = total number of operands.
also known as Halstead Software Science [2] [3] [12], to
calculate the software complexity on the basis of the source Several measures can be further computed on the basis of
code of any subsystem or even integrated software product. these numbers as-
This article describes how to apply Halstead software science
to a program written in five different programming languages.
This paper also checks the program’s relative metrics and
produce an analysis on the basis of selective and crucial
Authorized licensed use limited to: East Carolina University. Downloaded on July 27,2020 at 22:45:44 UTC from IEEE Xplore. Restrictions apply.
Proceedings of the Fourth International Conference on Trends in Electronics and Informatics (ICOEI 2020)
IEEE Xplore Part Number: CFP20J32-ART; ISBN: 978-1-7281-5518-0
Authorized licensed use limited to: East Carolina University. Downloaded on July 27,2020 at 22:45:44 UTC from IEEE Xplore. Restrictions apply.
Proceedings of the Fourth International Conference on Trends in Electronics and Informatics (ICOEI 2020)
IEEE Xplore Part Number: CFP20J32-ART; ISBN: 978-1-7281-5518-0
} if (Palindrome($orig inal))
while (num != 0); {
cout << " The reverse of the number is: " << reverse echo "It is a Palindrome number";
<< endl; }
if (n == reverse) else
cout << " The number is a palindrome."; {
else echo "It is not a Palindrome number";
cout << " The number is not a palindrome."; }
return 0; ?>
}
E. Program to check Palindrome in python
C. Program to check Palindrome in JAVA num=int (input(“Enter a number:”))
public class Palindrome temp=num
{ reverse=0
public static void main(String[] args) while temp !=0:
{ reverse = (reverse*10) + (temp%10)
int num = 171, reversedNum = 0, remainder, temp=temp//10
originalNum; if num==reverse:
originalNum = num; print (“It is a Palindrome number”)
while( num != 0 ) else:
{ print (“It is not a Palindrome number”)
remainder = num % 10;
reversedNum=reversedNum*10+remainder;
num /= 10; V. SOFT WARE SCIENCE CALCULAT IONS
} On the basis of source code written in different
if (originalNum == reversedNum) programming languages which are mentioned in section 3;
System.out.println(originalNum + " various Halstead metrics can be computed. These metrics
is a palindrome number."); collectively define the overall software complexity [4]. The
else Halstead software science for source codes mentioned in
System.out.println(originalNum + " section 3 are analyzed in Table 1.
is not a palindrome number.");
} TABLE I. HALSTEAD MTERICS ANALYSIS
}
S. Halstead Code Code Code Code Code
No. me trics in C in C++ in Java in PHP in
python
D. Program to check Palindrome in PHP 1 K1 21 23 27 17 16
<?php 2 K2 10 11 10 12 8
function Palindrome($number) 3 K 31 34 37 29 24
{ 4 N1 55 58 53 45 31
$temp = $number; 5 N2 27 29 26 27 20
6 N 82 87 79 72 51
$new = 0; 7 V 406.24 442.61 411.55 349.77 233.83
while (floor($temp)) 8 125.46 142.09 161.6 112.51 88
{ 9 D 28.35 30.32 35.1 19.12 20
$d = $temp % 10; 10 E 11516.9 13419.93 14445.4 6689.35 4676.6
$new = $new * 10 + $d; 11 T 639.83 745.55 802.52 371.63 259.81
12 B 0.135 0.147 0.137 0.116 0.078
$temp = $temp/10;
} VI. RESULT S
if ($new == $number)
{ All the above values mentioned in Table1, are based on
operators and operands that exists in the program(s). On the
return 1;
basis of the above analysis, it can graphically represent the
}
comparison of selective parameters such as difficulty, effort,
else time and bugs delivered. This comparison of parameters are
{ shown among all five experimented programming languages.
return 0;
} Following figure shows comparison of divergent values of
} difficulty among five different programming language. It can
be observed that the code written in Java language, has higher
$original = 171;
Authorized licensed use limited to: East Carolina University. Downloaded on July 27,2020 at 22:45:44 UTC from IEEE Xplore. Restrictions apply.
Proceedings of the Fourth International Conference on Trends in Electronics and Informatics (ICOEI 2020)
IEEE Xplore Part Number: CFP20J32-ART; ISBN: 978-1-7281-5518-0
degree of difficulty while code written in PHP has less degree Following figure shows comparison of divergent values of
of difficulty. bugs delivered among five different programming language. It
is observed that code written in C++ language has higher
degree of number of delivered bugs. While python has less
degree of number of delivered bugs.
Authorized licensed use limited to: East Carolina University. Downloaded on July 27,2020 at 22:45:44 UTC from IEEE Xplore. Restrictions apply.
Proceedings of the Fourth International Conference on Trends in Electronics and Informatics (ICOEI 2020)
IEEE Xplore Part Number: CFP20J32-ART; ISBN: 978-1-7281-5518-0
Advanced Studies in Computer Science and Engineering, Volume 1, [11] Rajib Mall, “ Fundamentals of Software Engineering”, Fourth Ed., PHI
Issue 1, pp. 1-11, June 2012. Learning Private Limited, (2016).
[6] Aparna T ripathi, Varsha Kumari, Nikhil Govil, "Impacts of PLC [12] Pankaj Jalote, “ An Integrated Approach to Software Engineering”, Third
Reducer on Software Design Cohesiveness", International Journal of Ed., Narose Publishing House, (2008).
Innovative Technology and Exploring Engineering, Volume-8 Issue-8, [13] https://en.wikipedia.org/wiki/Halstead_complexity_measures/ last
pp. 2871-2875, June 2019. accessed on 27 March 2020.
[7] V. Kumari, A. T ripathi, N. Govil and S. Pundhir, "A Proposed Model: [14] https://www.geeksforgeeks.org/software-engineering-halsteads-
Linearly Extensible T riplet Network (LET N)," 4th International software-metrics/last accessed on 27 March 2020.
Conference on Information Systems and Computer Networks (ISCON),
[15] https://www.javatpoint.com/software-engineering-halsteads-software-
Mathura, India, 2019, pp. 1-6.
metrics/ last accessed on 27 March 2020.
[8] Paul Goodman, “ Practical Implementation of Software Metrics”,
McGraw Hill Book Company, UK, 1993. [16] Rashmi Popli, Naresh Chauhan, “ Agile Estimation Using People and
Project Related Factors”, 2014 International Conference on Computing
[9] K.K.Aggarwal and Yogesh Singh, “ Software Engineering”, T hird Ed., for Sustainable Global Development (INDIACom), June 2014.
New Age International (P) Limited P ublishers. (2009).
[10] Roger S. Pressman, “Software Engineering: A Practitioner’s Approach”,
Fifth Ed., McGraw–Hill Higher Education, (2001).
Authorized licensed use limited to: East Carolina University. Downloaded on July 27,2020 at 22:45:44 UTC from IEEE Xplore. Restrictions apply.