A Metrics-Based Comparative Study on Object-Oriented Programming Languages.
Di Wu,Lin Chen,Yuming Zhou,Baowen Xu
DOI: https://doi.org/10.18293/seke2015-64
2015-01-01
Abstract:There has been a long debate on which programming language can help write better object-oriented programs.However, to date little response is given to this issue with empirical evidence.In this paper, we perform a comparative study on C++, C#, and Java programs by using object-oriented metrics, which comprise measures for class size, complexity, coupling, cohesion, inheritance, encapsulation, polymorphism, and reusability.Our experiment is conducted on 78 tasks in Rosetta Code, a code repository providing solutions to the same programming tasks in different languages.The experimental results show that: (1) C++ classes are significantly larger than C# and Java classes in size, but their complexity does not differ significantly; (2) C# classes are significantly more likely to be coupled than C++ and Java classes through inter-class method invocations instead of direct data access; (3) C# and Java classes tend to be more cohesive than C++ classes; (4) C# and Java significantly outperform C++ in building deep inheritance trees; and (5) programs written in C++, C#, and Java do not show a significant difference in class encapsulation, polymorphism, and reusability.These findings could help practitioners choose suitable languages to develop object-oriented systems.