Y
HN Search
Hacker News Search
new
|
comments
|
top
|
jobs
rogerkeays
searching PlanetScale…
1.
▲
2.
▲
3.
▲
4.
▲
5.
▲
6.
▲
8 ms
·
31.
▲
by
rogerkeays
3y ago
Interesting. Do you need to put the extension method in a utility class at all though? Could we put it in the Main class in the example?
32.
▲
by
rogerkeays
3y ago
Also, creating a subclass just to add extension methods is definitely boiler plate. Util classes too, though they are useful for packaging functions at least.
33.
▲
by
rogerkeays
3y ago
This! It even has a fancy name to satisfy the purists.
34.
▲
by
rogerkeays
3y ago
Yes, IDE support would help developers find the method that is being called. This is already quite a problem given we have complex class hierarchies and interfaces with default methods. I'm not sure I see the need for an annotation th
35.
▲
by
rogerkeays
3y ago
I can only speculate, but I think it is because extension methods can be shadowed if a vendor adds a method of the same name to the class you are extending. Of course, that depends on how you resolve methods. In java, this would be a comp
36.
▲
by
rogerkeays
3y ago
Yes.
37.
▲
by
rogerkeays
3y ago
Kotlin is great, but it is a fairly heavy dependency if all you want is extension methods. Java has mostly caught up in many other aspects, so I'm experimenting with Java + one or two compiler hacks. Checked exceptions are my next targ
38.
▲
by
rogerkeays
3y ago
Oof... looks more object-oriented hell to me. I really like the way functional programming languages separate types from functions, and I've been adopting this pattern in my Java code. Extension methods let you do this and keep your fl
39.
▲
by
rogerkeays
3y ago
I never saw the need for annotating extension methods like in Lombok or Manifold . Lombok is great for other stuff though.
40.
▲
Fluent: Static Extension Methods for Java
(github.com)
79 points
by
rogerkeays
3y ago
|
114 comments
41.
▲
Show HN: Unchecked – Evade the checked exception mafia (Java)
(github.com)
1 points
by
rogerkeays
4y ago
|
0 comments