#130 Defensive overloading

Future
closed
nobody
None
5
2015-10-22
2002-12-29
No

Bloch, Effective Java, Item 26:

Never export two overloadings with the same number of
parameters.

Bloch mentions that using overloading with the same
number of params might be OK if the parameter types are
unrelated, i.e. no class is a descendant of the other.

Limitation: It will probably not be possible to check
for overloading across inheritance hierarchies, as in

class A {
public boolean isCool(Object x) {
return false
}
}

class B {
public boolean isCool(HashMap y) {
return true;
}
}

Discussion

  • Roman Ivanov

    Roman Ivanov - 2015-10-22
    • status: open --> closed
    • Group: --> Future
     
  • Roman Ivanov

    Roman Ivanov - 2015-10-22

    Checkstyle is not type aware by design , we can not check for Types inheritance at all.

     

Log in to post a comment.