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

4

u/[deleted] Mar 09 '16

[removed] — view removed comment

5

u/kmaibba Mar 09 '16

That's a cultural problem though. Somewhere, someone along the way decided that you MUST have an ISomething for every Something, and while we're at it, have an ASomething too! And then use an ASomethingFactory and an SomethingFactoryImpl to instantiate the SomethingImpl. To top it all off, offload all the EVIL MUST NOT USE "new" to a DI Framework and configure it in XML-files. That should do the trick. Your code is now "maintainable", because when you change something, you just have to implement the interface and the edit some XML file, as opposed to just changing one line of the fucking implementation. Fuck actually being able to debug and read stuff, right?

Got a new guy at work who writes code like this and it's a nightmare to read. I mean the actual implementation is 20 lines of trivial CRUD code, why do you need 4 support classes/interfaces spread over 3 packages? Why can't you you just write a simple class, write some tests and the do your silly abstractions the moment you actually need them (hint: you won't need them 99% of the time, and the other 1% you will need to change all the other stuff anyway because of unforseen new requirements).

OT though, I hope and am pretty sure that they won't implement the var keyword. All it does is reduce readability and save some keystrokes. Verbosity is not a bad thing. It might look clumsy when you compare it to some hipster language tutorial, and it might suck a little bit while writing the code, but when reading and understanding the code later, it's a godsend.

1

u/[deleted] Mar 09 '16

[removed] — view removed comment

1

u/immibis Mar 10 '16

However, interfaces let you have multiple implementations that can all be in use at the same time. They also allow the compiler to yell at you if you forget to implement a method.

(This applies to abstract classes too, of course. I hope you were saying that both are bad, not that interfaces are bad and everyone should use abstract classes instead)

→ More replies (2)