The Use of Overloading in Java Programs

Keren Lenz, Ph.D. Thesis Seminar
Wednesday, 19.9.2012, 13:00
Taub 601
Prof. Joseph (Yossi) Gil

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 talk 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.

Back to the index of events