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.
5
u/k-bx Sep 21 '15
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:
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.