Previous research has highlighted the extensive use of the C++ friend construct in both library-based and application-based systems. However, existing software metrics do not concentrate on measuring friendship accurately, a surprising omission given the debate friendship has caused in the Object-Oriented community. In this paper, a number of software metrics, that measure the extent to which friend class relationships are actually used in systems, are de ned. These metrics are based on
the interactions for which the friend construct is necessary, as well as the direction of this association between classes.
Our results, in applying these metrics to the top 100 downloaded systems from sourceforge.net, indicate that up to 66% of friend class relationships in systems are redundant. Elsewhere, friend function declarations would have been more appropriate in many cases. In addition, it has been shown that friendship-based coupling contributes significantly to the high coupling of friend classes for only 25% of the systems studied.
History
Publication
2005 International Symposium on Empirical Software Engineering;pp. 469-478