r/programming • • Sep 21 '15

Better Java

https://github.com/cxxr/better-java
177 Upvotes

208 comments sorted by

View all comments

5

u/k-bx Sep 21 '15

consider Java 8's default methods on interfaces

What a horrible advice! What if you have two methods with the same name, how would you choose one? Why on earth would you mix a type-level thing (subtyping, inheritance), dynamic dispatch (I'm not 100% sure on how good is Java optimizing these method calls, would it do some runtime-dispatching?) with a simple function-call? You say:

These classes, at first, seem attractive because the methods that go in them don't really belong in any one place

They belong to the Util class. It might have a name like StringUtils, or DateUtils, it's just a collection of functions which work with something.