I’m a huge believer in consistency, and hence conventions.
However, I’m currently developing a framework in Java where these conventions (specifically the get
Josh Bloch actually sides with you in this matter in Effective Java, where he advocates the get
-less variant for things which aren't meant to be used as beans, for readability's sake. Of course, not everyone agrees with Bloch, but it shows there are cases for and against dumping the get
. (I think it's easier to read, and so if YAGNI, ditch the get
.)
Concerning the size()
method from the collections framework; it seems unlikely it's just a "bad" legacy name when you look at, say, the more recent Enum
class which has name()
and ordinal()
. (Which probably can be explained by Bloch being one of Enum
's two attributed authors. ☺)