Software Testability in Object-Oriented and Functional Programming : a Comparative Study in Kotlin
Pham, Dung (2026)
Pham, Dung
2026
All rights reserved. This publication is copyrighted. You may download, display and print it for Your own personal use. Commercial use is prohibited.
Julkaisun pysyvä osoite on
https://urn.fi/URN:NBN:fi:amk-2026051211409
https://urn.fi/URN:NBN:fi:amk-2026051211409
Tiivistelmä
Software testability, a subcharacteristic of maintainability in the ISO/IEC 25010 Product Quality model, describes how effectively and efficiently a software system can be verified through testing. The effort required for testing is influenced by how software is designed, including the choice of programming paradigm. Object-oriented and functional programming represents two distinct approaches to software design, each with different sets of core concepts and principles that may affect testing effort differently.
This thesis report presents an empirical comparison of testability between object-oriented and functional programming implementations in Kotlin. Identical application functionality was developed in both paradigms and assessed using four metrics: source lines of code, test lines of code, cyclomatic complexity, and mock and stub count. These metrics were selected based on their association with the testability factors of controllability, observability, and isolateability identified in the literature.
The results show that the functional design required fewer lines of code in both source and test code and did not need mocking infrastructure to achieve complete test coverage, compared to three mock objects required in object-oriented test suite to substitute the dependencies. Cyclomatic complexity was equal between the two prototypes at this limited scale. Overall, the findings partially support the theoretical suggestion that functional programming approach contributes positively to testability, with notable advantages in test isolation and test setup effort.
This thesis report presents an empirical comparison of testability between object-oriented and functional programming implementations in Kotlin. Identical application functionality was developed in both paradigms and assessed using four metrics: source lines of code, test lines of code, cyclomatic complexity, and mock and stub count. These metrics were selected based on their association with the testability factors of controllability, observability, and isolateability identified in the literature.
The results show that the functional design required fewer lines of code in both source and test code and did not need mocking infrastructure to achieve complete test coverage, compared to three mock objects required in object-oriented test suite to substitute the dependencies. Cyclomatic complexity was equal between the two prototypes at this limited scale. Overall, the findings partially support the theoretical suggestion that functional programming approach contributes positively to testability, with notable advantages in test isolation and test setup effort.
