Keyword- and Default- Parameters in JAVA.
Joseph Yossi Gil, Keren Lenza · The Journal of Object Technology · 2012
Overloading is a highly controversial programming language mechanism by which different methods of the same class are allowed to bear the same name.Despite the criticism, JAVA programmers make extensive use of this mechanism-not just because it is available, but also because the language does not provide an alternative for defining multiple constructors, and because it is useful for expressing similarity of services provided by a class.In a previous paper we argued that more than 60% of the overloading cases are "justifiable" and that in 35% of the cases overloading is used for emulating a default arguments mechanism.Based on these results, this paper argues that most "justifiable" uses of overloading are better done with a combination of keyword parameters and default parameters parameter definition mechanisms, and describes our extension of the JAVA compiler which adds these two features to the language.For the class's author, this emulation of default parameters means a blown up interface with extra code to document and maintain.In this example, the three-lined function getInteger(String) incurs a 28-lines documentation overhead toll.For the class's client, this practice requires familiarity with different versions of essentially the same method, and