Abstract
Use of friends in C++ software is widely considered as poor programming practice. However, little empirical evidence exists to support this belief. In this paper, the results of a case-study based investigation into the use of friends in object-oriented software are described. Four C++ systems of varying sizes were analysed and data related to friends collected for each. Class metrics were collected from each of the systems. Five hypotheses were then investigated. Results showed a lack of statistical significance with any of the class metrics collected. No evidence was found to support the hypothesis that classes declared as friends of other classes used inheritance any less than other classes. Strong evidence was found, however, to support the hypothesis that, firstly, friends tended to be found in classes deep in the inheritance hierarchy; secondly, that classes not engaging in inheritance use friends considerably more than classes that do. Empirical evidence also suggests that friends are used primarily as a means for facilitating operator overloading. The results in this paper highlight the need for more investigation in this area and into the wider issues of class coupling.
Talk to us
Join us for a 30 min session where you can share your feedback and ask us any queries you have
Disclaimer: All third-party content on this website/platform is and will remain the property of their respective owners and is provided on "as is" basis without any warranties, express or implied. Use of third-party content does not indicate any affiliation, sponsorship with or endorsement by them. Any references to third-party content is to identify the corresponding services and shall be considered fair use under The CopyrightLaw.