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

18

u/[deleted] Mar 09 '16

[removed] — view removed comment

15

u/RobIII Mar 10 '16

I wish C# have final or something equivalent for local variables.

Watch this one: Proposal: 'readonly' for Locals and Parameters

1

u/mirhagk Mar 10 '16

It's likely to make it into C# 7 as well, it was highly desired for C# 6.

1

u/MacASM Mar 10 '16

This isn't going to change unless they change CLR spec too. That's why there's no readonly for locals.

9

u/ummmyeahright Mar 10 '16

No. The comments about CLR change requirement are about other features suggested in comments (also not actually necessary for 99.9% of cases, just more convenient to implement them that way).

Readonly locals don't 'require' any change to the CLR.

-9

u/[deleted] Mar 09 '16

Stop writing long functions?

18

u/The_Jacobian Mar 09 '16

Translation: Stop working in projects that existed before you were a part of them or before you were as skilled as you are now.

-13

u/[deleted] Mar 09 '16

Or you have the responsibility to make the code you work with better. "It's the way it is" is simply a cop out...

18

u/The_Jacobian Mar 10 '16

A blank check to refactor is rare and hard to come by. I'd love to see a company where you're allowed to clean up every piece of code you ever touch but I suspect they're rare and incredibly rich.

I work in a 10 year old application that has been under constant development for that whole time. Huge chunks of it would take weeks to clean up well (written long ago in a huge rush, as is normal for early stage startups), if I'm there investigating one small issue I can't justify the cost and risk of an in depth refactor.

On the other side of the coin I'm currently in charge of a project to rewrite the entire payments, billing and accounting potion of this application and its being cleaned up because we managed to sell it to the people who hold the money.

No need to assume you're the only person whose ever tried to be good at their job, I assume most of us here know not to write 1000 line methods...

0

u/mirhagk Mar 10 '16

As much as /u/SalizarMarxx is being sorta naive about large code bases and the difficulty to refactor, refactoring does not have to be a very time consuming process. C# and visual studio have pretty good refactoring tools and if you are working with legacy code you should at least do a minor refactor of a function that is long horrible and ugly. Even a variable rename, or inverting an if statement, switching to foreach or a number of other tiny changes can help improve a function. And if you get in a mode where you do a single minor refactor each time you touch the code then the code will slowly get better.

Bigger refactorings are certainly tricky, extract method is extremely useful, but it's not always possible. However visual studio does have pretty great support for automatically doing it, and even if it requires passing variables by reference into it it's still potentially better.

2

u/DingDongHelloWhoIsIt Mar 09 '16

Maybe he didn't write them

1

u/[deleted] Mar 10 '16

[removed] — view removed comment

1

u/DingDongHelloWhoIsIt Mar 10 '16

Go on then, how many lines we talking?