Lots of static methods in an interface

Zhong Yu zhong.j.yu at gmail.com
Tue Sep 10 09:17:01 PDT 2013


It seems that the standard lib is settling on the convention of
putting static methods directly in the relevant interface, e.g.
Comparator, instead of in another companion class, e.g. Comparators. I
was against it before but now I think it is great - no need to direct
users to another place to look for related methods.

However I still find the javadoc landing page very messy:

http://download.java.net/jdk8/docs/api/java/util/Comparator.html#method_summary

with static/abstract/default methods mixed together indiscriminately.
Sure there are tabs, but there is no reason to give a bad first
impression to users. Static/abstract/default methods are so different,
does anybody really want an alphabetic index containing all of them?
Even if they do, can't we move that index page to a less important
tab? Wouldn't it be much more readable if the landing page shows all
methods in different groups?

Abstract Methods
--------------------------------------
int     compare(T o1, T o2)
boolean     equals(Object obj)

Default Methods
--------------------------------------
Comparator<T>     reversed()
Comparator<T>     thenComparing(...)
...

Static Methods
--------------------------------------
Comparator<T>     comparing(...)
...
Comparator<T>     naturalOrder()
...



Zhong Yu


More information about the lambda-dev mailing list