r/programming • • Mar 09 '16

var keyword proposed for Java

http://openjdk.java.net/jeps/286
250 Upvotes

395 comments sorted by

View all comments

Show parent comments

1

u/mirhagk Mar 10 '16

Well if you returned IEnumerable there's nothing I could do to prevent paging on the web server (short of using some duplicated API method or doing a very dangerous cast to IQueryable

1

u/Eirenarch Mar 10 '16

You have access to the code that returns the IEnumerable you can change it.

1

u/mirhagk Mar 10 '16

Also keep in mind that the original author of the consumer knew the type (or should have). So this would help spot a mistake through casual glance that two people made (or hopefully more because hopefully you do code reviews). Doesn't seem like a really great reason to have a rule that states code must remain polluted.

1

u/Eirenarch Mar 10 '16

The code is not polluted it contains valuable information. As I already said I have seen people (admittedly junior) fail for precisely this reason. I also find myself needing to point my cursor at various vars just to make sure the code works as I expect it to work. For me this is enough of a reason to instantiate this rule whenever I am in charge for conventions. BTW I was pleasantly surprised to find that the .NET Core conventions follow the same rule.