Software complexity; How do you measure your source code?

source : https://t4tutorials.com/cyclomatic-complexity-of-a-graph/

According to Debbarma et al. (2013), the complexity of software is based on the quality of code with respect to the degree of complexity of subroutine, methods, classes, functions in the software. Among the characteristics of good code are readability, reliability, durability, maintainability just to mention but a few, when some of these are not achieved or implemented in the software, therefore, the software is complex. Software complexity is based on software metrics (Debbarma et al., 2013), over the years, so many metrics have been proposed such as quality of code (Baresi & Pezzè, 2006), ease of testability of software (Sommerville, 2016), software maintainability (Boehm, 1983) and other researchers have analyzed that software is less complex if customer satisfaction is meant both at the point of delivery and the whole process of development (Holtsnider et al., 2010).

Software complexity is a measure of the degree of interaction of software components such as a number of lines of code (LOC), Halstead metrics: operators and operands from the source code (Al-Qutaish & Abran, 2010), Cyclomatic complexity: conditional and loops from the source code (Cyclomatic Complexity, n.d.) and maintainability index. Therefore, a code with good complexity contains fewer errors, easier to understand and maintain. However Holtsnider et al. (2010) context this view in explaining that software complexity metrics are based on the software dimensions and artefacts.

Line of code metrics is a traditional way of measuring software complexity by counting the number of lines of code, physical line, block, number of comment lines, number of blank lines, it is found simple and easy to understand. According to Holtsnider et al. (2010), 60 lines is the most common fit limit for a line of code in a file. Contrary to this view Authur and McCabe (1996) agree that a software module should fit in for one page for ease of management. Line of code(LOC) describes the dimension of software artefact by measuring the logical(statement) and physical(lines) of the code file.

The view of support for software complexity is further advocated by Maurice Howard Halstead, 1997 by introducing measurement of software complexity by calculation of operands and operators in the source code. Halstead believes that computer software is the implementation of the algorithm as such is a collection of total unique numbers of operands and operators, technically the theory Halstead’s is based on these four qualities, number of the unique operators (n1), number of the unique operands (n2), number of total occurrence operators(N1) and number of total occurrence operands(N2).

The last one to measure software complexity is proposed by McCabe, 1974. It is called cyclomatic metrics of measuring software complexity which state that source code is measure by a total number of condition decision making in the programs such as do-while, if-else, repeat-until, switch cases and go-to statement.

In closing, source code complexity is quantifiable or measured by counting the total line of code(KLOC), counting the total number of conditional loops statement from the source code (McCabe theory) and by counting the total number of unique operators and operands from the source code(Halstead theory).

References

Al-Qutaish, R., & Abran, A. (2010). Halstead Metrics: Analysis of their Design (pp. 145–159). https://doi.org/10.1002/9780470606834.ch7

Baresi, L., & Pezzè, M. (2006). An Introduction to Software Testing. Electronic Notes in Theoretical Computer Science, 148(1), 89–111. https://doi.org/10.1016/j.entcs.2005.12.014

Boehm, B. W. (1983). Seven basic principles of software engineering. Journal of Systems and Software, 3(1), 3–24. https://doi.org/10.1016/0164-1212(83)90003-1

Cyclomatic Complexity. (n.d.). Retrieved August 28, 2021, from https://www.tutorialspoint.com/software_testing_dictionary/cyclomatic_complexity.htm

Debbarma, M. K., Debbarma, S., Debbarma, N., Chakma, K., & Jamatia, A. (2013). A Review and Analysis of Software Complexity Metrics in Structural Testing. International Journal of Computer and Communication Engineering, 129–133. https://doi.org/10.7763/IJCCE.2013.V2.154

Holtsnider, B., Wheeler, T., Stragand, G., & Gee, J. (2010). Chapter 2 — The Problem: Why Software Projects Fail. In B. Holtsnider, T. Wheeler, G. Stragand, & J. Gee (Eds.), Agile Development & Business Goals (pp. 11–29). Morgan Kaufmann. https://doi.org/10.1016/B978-0-12-381520-0.00002-3

Sommerville, I. (2016). Software engineering. http://www.dawsonera.com/depp/reader/protected/external/AbstractView/S9781292096148

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
James Oladimeji

I have always wanted to know how things work. I hate magic. This curiosity has driven me to programming, Java is my first and is to death do us part.