Refurbishment of object-oriented code: A methodical approach to minimize program complexity
DOI:
https://doi.org/10.31181/jdaic10018052025kKeywords:
test coverage, software testing, path coverage, complexity, object-orientedAbstract
In order to determine software testing competence, test coverage analysis techniques are commonly implemented. The uncovered areas or statements of a program are identified using a technique that employs a set of test cases best suited for the program. Depending on the current approach or the complexity of the program, the concept of test coverage is especially useful in identifying and eliminating test cases that do not contribute significantly to achieving the desired output. In other words, this technique helps in making a program more robust and error-free. It is also useful for identifying sections of a requirement that are not covered by existing test cases. The technique is helpful in creating new test cases to enhance the coverage of a program. As a rigorous quality control practice, it supports the development of experimental test coverage metrics. Therefore, ineffective test scenarios that do not contribute to increased coverage should be tracked and eliminated, thereby reducing the overall complexity of the program.
Our approach in this paper aims to create a Control Flow Graph (CFG) for randomly generated object-oriented programs in Java and assess the cyclomatic complexity for each by analyzing the nodes and edges using the traditional formula from the software engineering paradigm. We then identify the best approach to write the program by applying prioritization techniques to the calculated complexity values of the object-oriented programs. This enables us to minimize the complexity of the program during the code development process.
Downloads
References
Abdelmoez, W., Shereshevsky, M., Gunnalan, R., Ammar, H., Yu, B., Bogazzi, S., Korkmaz, M., & Mili, A. (2005). Quantifying software architectures: An analysis of change propagation probabilities. Proceedings of the 21-st IEEE International Symposium on Defect and Fault-Tolerance in VLSI Systems (pp. 124-). Cairo: IEEE.
Aho, A. V., Sethi, R., & Ullman, J. D. (1986). Compilers: Principles, techniques, and tools. Boston: Addison-Wesley Longman Publishing Co.
Allen, F. E. (1970). Control flow analysis. ACM SIGPLAN Notices, 5(7), 1–19.
Ammann, P., & Offutt, J. (2008). Introduction to software testing. Cambridge: Cambridge University Press.
Bergel, A., & Peña, V. (2014). Increasing test coverage with HAPAO. Science of Computer Programming, 79, 86–100.
Beyene, M. S. (2021). Source-code Summarization of Java Methods Using Control-Flow Graphs. Master of Science Thesis. Saskatoon: University of Saskatchewan.
Binder, R. V. (2009). Testing object-oriented systems: Models, patterns, and Tools. Addison-Wesley.
C2nes. (n.d.). GitHub - c2nes/javalang: Pure Python Java parser and tools. GitHub. https://github.com/c2nes/javalang, Accessed 13 March 2025.
Cao, J., Chen, Z., Wu, J., Cheung, S.-C., & Xu, C. (2024). JavaBench: A Benchmark of Object-Oriented Code Generation for Evaluating Large Language Models. Proceedings of the 39th IEEE/ACM International Conference on Automated Software Engineering (ASE '24), (pp. 870 – 882). New York: Association for Computing Machinery.
Cardoso, J. (2008). Business Process Control-Flow complexity: Metric, Evaluation, and Validation. International Journal of Web Services Research, 5(2), 49–76.
Chen, J., Zhu, L., Chen, T. Y., Towey, D., Kuo, F.-C., Huang, R., & Guo, Y. (2018). Test case prioritization for object-oriented software: An adaptive random sequence approach based on clustering. Journal of Systems and Software, 135, 107–125.
Do, H., Elbaum, S. & Rothermel, G. (2005). Supporting Controlled Experimentation with Testing Techniques: An Infrastructure and its Potential Impact. Empirical Software Engineering, 10, 405–435.
Ghoreshi, M., & Haghighi, H. (2023). Object coverage criteria for supporting object-oriented testing. Software Quality Journal, 31, 1369–1414.
Gold, R. S. (2010). Control flow graphs and code coverage. International Journal of Applied Mathematics and Computer Science, 20(4), 739–749.
Gong, D., Zhang, W., & Yao, X. (2011). Evolutionary generation of test data for many paths coverage based on grouping. Journal of Systems and Software, 84(12), 2222–2233.
Goud, R. E. H., Kishore, C., & Asadi, S. (2015). Test Data Generator to improve code coverage in Object Oriented Programming. i-Manager’s Journal on Software Engineering, 10(2), 30–37.
Graphviz (2022). PyPI. https://pypi.org/project/graphviz/, Accessed 23 September 2024.
Gupta, M., Rajnish, K., & Bhattacherjee, V. (2022). Cognitive Complexity and Graph Convolutional Approach Over Control Flow Graph for Software Defect Prediction. IEEE Access, 10, 108870–108894.
Hossain, S. B., & Dwyer. M.B. (2022). A Brief Survey on Oracle-Based Test Adequacy Metrics. arXiv, https://doi.org/10.48550/arXiv.2212.06118.
Indumathi, C. P., & Vinothini, N. (2018). Enhancing fault localization using control and data flow dependence structures. Proceedings of the 2nd International Conference on Inventive Systems and Control (ICISC) (pp. 1291-1296). Coimbatore: IEEE.
Jo, J. W., & Chang, B. M. (2004). Constructing Control Flow Graph for Java by Decoupling Exception Flow from Normal Flow. In Laganá, A., Gavrilova, M.L., Kumar, V., Mun, Y., Tan, C.J.K., Gervasi, O. (eds), Computational Science and Its Applications – ICCSA 2, Lecture Notes in Computer Science (pp. 106–113), Vol. 3043. Berlin: Springer.
Khan, M. A., & Sadiq, M. (2011). Analysis of black box software testing techniques: A case study. Proceedings of the International Conference and Workshop on Current Trends in Information Technology (CTIT 11) (pp. 1-5). Dubai: IEEE.
Kumar, K. S., & Malathi, D. (2017). A Novel Method to Find Time Complexity of an Algorithm by Using Control Flow Graph. Proceedings of the International Conference on Technical Advancements in Computers and Communications (ICTACC), (pp. 66-68). Melmaurvathur: IEEE.
Landin, P. J. (1966). The next 700 programming languages. Communications of the ACM, 9(3), 157–166.
Li, J., Tan, Q., & Xu, J. (2010). Reconstructing control flow graph for control flow checking. Proceedings of the International Conference on Progress in Informatics and Computing (pp. 527-531). Shanghai: IEEE.
Liu, L., Ci, L., Liu, W., & Bin, C. (2016). Control-Flow Checking Using Branch Sequence Signatures. Proceedings of the International Conference on Internet of Things (iThings) and IEEE Green Computing and Communications (GreenCom) and IEEE Cyber, Physical and Social Computing (CPSCom) and IEEE Smart Data (SmartData) (pp. 839-845). Chengdu: IEEE.
Mall, R. (2004). Fundamentals of Software Engineering. 2nd ed. Delhi: Prentice-Hall of India Pvt.Ltd.
Matplotlib (n.d.). Matplotlib: Visualization with Python. https://matplotlib.org/, Accessed 18 September 2024.
Mohamed, A., & Zulkernine, M. (2012). A Control Flow Representation for Component-Based Software Reliability Analysis. Proceedings of the Sixth International Conference on Software Security and Reliability (pp. 1-10). Gaithersburg: IEEE.
Mohammad, C. W., Shahid, M., & Husain, S. Z. (2017). A graph theory based algorithm for the computation of cyclomatic complexity of software requirements. Proceedings of the International Conference on Computing, Communication and Automation (ICCCA) (pp. 881-886). Greater Noida: IEEE.
Najumudheen, E. S. F., Mall, R., & Samanta, D. (2009). A dependence graph-based test coverage analysis technique for object-oriented programs. Proceedings of the Sixth International Conference on Information Technology: New Generations (pp. 763-768). Las Vegas: IEEE.
Najumudheen, E. S., Mall, R., & Samanta, D. (2011). Test coverage analysis based on an object-oriented program model. Journal of Software Maintenance and Evolution: Research and Practice, 23(7), 465–493.
NetworkX. (n. d). DiGraph—Directed graphs with selfloops — NetworkX 3.2.1 documentation. https://networkx.org/documentation/stable/reference/classes/digraph.html, Accessed 27 September 2024.
Odeh, A. H., Odeh, M., Odeh, H., &Odeh, N. (2023). Measuring Cyclomatic Complexity of Source Code Using Machine Learning. Revue d'IntelligenceArtificielle, 38(1), 183-191.
Pathik, B., & Sharma, M. (2021). Analysis of Effort Estimation for Test Suite using Control Graph. Proceedings of the International Conference on Artificial Intelligence and Machine Vision (AIMV) (pp. 1-6). Gandhinagar: IEEE.
Pawade, D., Dave, D. J., & Kamath, A. (2016). Exploring software complexity metric from procedure oriented to object oriented. Proceedings of the 6th International Conference - Cloud System and Big Data Engineering (Confluence) (pp. 630-634). Noida: IEEE.
Qingfeng, D. & Xiao, D. (2011). An improved algorithm for basis path testing. Proceedings of the International Conference on Business Management and Electronic Information (pp. 175-178). Guangzhou: IEEE.
Sakti, A., Pesant, G., & Gueheneuc, Y.-G. (2015). Instance Generator and Problem Representation to Improve Object Oriented Code Coverage. IEEE Transactions on Software Engineering, 41(3), 294–313.
Santelices, R., Jones, J. A., Yu, Y., & Harrold, M. J. (2009). Lightweight fault-localization using multiple coverage types. Proceedings of the 31st International Conference on Software Engineering (pp. 56-66). Vancouver: IEEE.
Sedaghat, Y., Miremadi, S. G., & Fazeli, M. (2006). A Software-Based error detection technique using encoded signatures. Proceedings of the 21st IEEE International Symposium on Defect and Fault Tolerance in VLSI Systems (pp. 389-400). Arlington: IEEE.
Shah, H. (2023). A detailed guide on test coverage.Simform - Product Engineering Company. https://www.simform.com/blog/test-coverage/, Accessed 18 September 2024.
Sneed, H. M. (2010). Testing object-oriented software systems. Proceedings of the 1st Workshop on Testing Object-Oriented Systems (ETOOS '10) (pp. 1-5). New York: Association for Computing Machinery.
Spasova, G., & Boychev, I. (2023). Development of a Java Syntax Analyzer for C/C++ Code Recognition. Proceedings of the International Conference Automatics and Informatics (ICAI) (pp. 45-48). Varna: IEEE.
Tian, F., Zhang, Y., & Ma, D. (2011). An algorithm of program structure adjustment base on interactive disassembly. Proceedings of the 2nd International Conference on Software Engineering and Service Science (pp. 860-863). Beijing: IEEE.
TKInter - Python Wiki. (n. d.). TKInter. https://wiki.python.org/moin/TkInter, Accessed 17 September 2024.
Vincenzi, A. M. R., Maldonado, J. C., Wong, W. E., & Delamaro, M. E. (2005). Coverage testing of Java programs and components. Science of Computer Programming, 56(1–2), 211–230.
Wang, H., Xu, C., Sui, J., & Lu, J. (2016). How Effective Is Branch-Based Combinatorial Testing? An Exploratory Study. Proceedings of the International Conference on Software Quality, Reliability and Security (QRS) (pp. 41-52). Vienna: IEEE.
Wijayasiriwardhane, K. T., Wijayarathna, P. G., & Karunarathna, D. D. (2011). An automated tool to generate test cases for performing basis path testing. Proceedings of the International Conferences on Advances in ICT for Emerging Regions (ICTer), (pp. 95-101). Colombo: IEEE.
Wijendra, D. R., & Hewagamage, K. P. (2022). Cognitive Complexity Reduction through Control Flow Graph Generation. Proceedings of the 7th International Conference for Convergence in Technology (I2CT) (pp. 1-7). Mumbai: IEEE.
Wong, W.E., Gao, R., Li, Y., Abreu, R. & Wotawa, F. (2016). A survey on software fault localization.
IEEE Transactions on Software Engineering, 42(8), 707–740.
Woodward, M. R., Hennell, M. A., & Hedley, D. (1979). A measure of control flow complexity in program text. IEEE Transactions on Software Engineering, SE-5(1), 45–50.
Xu, W., El Ariss, O., & Liu, Y. (2018). An Empirical Study of Control Flow Graphs for Unit Testing. In: Latifi, S. (ed.), Information Technology - New Generations. Advances in Intelligent Systems and Computing (pp. 545-553), Vol. 558. Cham: Springer.
Yang, Q., Li, J. J., & Weiss, D. (2006). A survey of coverage based testing tools. Proceedings of the 2006 international workshop on Automation of software test (AST '06) (pp. 99-103). New York: Association for Computing Machinery.
Zapata, F., Akundi, A., Pineda, R., & Smith, E. (2013). Basis path analysis for testing complex system of systems. Procedia Computer Science, 20, 256–261.
Zhang, J., Wang, X., Zhang, H., Sun, H., Wang, K., & Liu, X. (2019). A Novel Neural Source Code Representation Based on Abstract Syntax Tree. Proceedings of the ACM 41st International Conference on Software Engineering (ICSE), (pp. 783-794). Montreal: IEEE.
Zhonglin, Z., & Lingxia, M. (2010). An improved method of acquiring basis path for software testing. Proceedings of the 5th International Conference on Computer Science and Education (pp. 1891-1894). Hefei: IEEE.