The use of overloading in JAVA programs

  • Authors:
  • Joseph Gil;Keren Lenz

  • Affiliations:
  • IBM Haifa Research Laboratory, Israel;Department of Computer Science, The Technion, Haifa, Israel

  • Venue:
  • ECOOP'10 Proceedings of the 24th European conference on Object-oriented programming
  • Year:
  • 2010

Quantified Score

Hi-index 0.00

Visualization

Abstract

Method overloading is a controversial language feature, especially in the context of Object Oriented languages, where its interaction with overriding may lead to confusing semantics. One of the main arguments against overloading is that it can be abused by assigning the same identity to conceptually different methods. This paper describes a study of the actual use of overloading in JAVA. To this end, we developed a taxonomy of classification of the use of overloading, and applied it to a large JAVA corpus comprising more than 100,000 user defined types. We found that more than 14% of the methods in the corpus are overloaded. Using sampling and evaluation by human raters we found that about 60% of overloaded methods follow one of the "non ad hoc use of overloading patterns" and that additional 20% can be easily rewritten in this form. The most common pattern is the use of overloading as an emulation of default arguments, a mechanism which does not exist in JAVA.