3 ms·
A lot of the time _private_ methods on one class end up making more sense as public methods on a helper class of some kind (or public methods on other classes).
by fiddlerwoaroof 3y ago
A lot of the time _private_ methods on one class end up making more sense as public methods on a helper class of some kind (or public methods on other classes).
One issue that leads to private methods in Java is the lack of any way to extend the set of operations on built-in classes: a problem that Kotlin and C# solve with extension methods.
- kaba0 3y agoExtension methods are basically just static methods in a helper class that takes the to be extended class as their first argument, and a bit of syntactic sugar on top. That is absolutely imitable in Java.
- fiddlerwoaroof 3y agoYou can imitate it in Java, but the ergonomics are worse.