r/javahelp • u/dg_713 • Sep 30 '19
What features did Java have that you wished you've learned way back?
An offshoot of a post from r/learnprogramming, but since I want to concentrate on Java for now.
Thanks everyone!
13
u/mentholmeow Sep 30 '19
The java startup VM arguments to make the classloader verbose - it really helps when trying to troubleshoot issues related to class loading.
3
9
4
u/E3FxGaming Sep 30 '19 edited Sep 30 '19
Not really a Java feature, but ORM.
I wish I knew more about object-to-rationale mapping (ORM) before I invested unnecessary effort into the "plain" SQL capabilities of Java.
Just to get this out of the way, neither approach replaces learning about SQL (this is a sub for aspiring developers so I thought it is necessary to mention this). I already had a decent understanding of SQL after it was taught to me at school and I came with this knowledge to Java thinking "Oh Java has those SQL classes here, this must be how all the people use SQL with Java. Make a database scheme and prepare the database, create a db connection in Java and write PreparedStatement, ...".
Last month I used an ORM framework for the first time (for me it was with the Apache Cayenne framework... there are many out there, everyone will find one that fits their needs). This was just such a game changer for my task at hand, getting rid of all the tedious manual SQL work and getting back to what I consider "real/actual" Java programming (developing the business logic of my program without worrying about the SQL resources).
Next I want to climb the mountain I see in "Spring" - I hope I can get a productivity boost similar to the one I got with ORM by learning how to use Spring.
Putting frameworks aside
Java 8 streams are nice, wish I knew about them before I wrote that long program
How to send GET and POST HTTP-Requests with Java - this one opened a lot of doors for potential new training projects. There is just an unbelievable amount of public REST-APIs and a (sadly) much smaller, but (IMHO) more enjoyable to use amount of public GraphQL-APIs out there that one can simply interact with. I don't really like the native Java HTTP-Request way and prefer using a library such as Apache Httpclient, but in the end this point is more about understanding that one can interact with other services by making use of those public APIs. My projects that involved using 3rd party APIs were easily some of my most rewarding projects in terms of gained knowledge and satisfaction with the result.
5
Sep 30 '19
Spring is a total game changer. Spring boot in particular, once you get comfortable with it you'll wonder how the hell you ever did anything else.
I found IoC a bit tricky to get my head around, but once you do it's great. Spring is a configuration framework.1
u/E3FxGaming Sep 30 '19
Thank you for your reply. Now I'm looking forward to using Spring even more.
1
Sep 30 '19
Spring boot is a bit mad. It tries to do everything for you. You have to tell it what NOT to do. So for example if you have an external database you have to tell it you don't need a database.
3
u/nutrecht Lead Software Engineer / EU / 20+ YXP Sep 30 '19
That really is not true. If you don't include the dependencies Spring doesn't even know about the concept of a database. If you don't include Spring Security it doesn't know about security. Etc.
2
3
u/wildjokers Sep 30 '19
Oh, you are still in the “love ORM” phase. Give it a while you will soon be in the “hate ORM” phase. (May take a few years).
Make sure you pay close attention to the SQL it is generating. You will soon find out that ORMs are brain-dead when it comes to querying.
3
u/gregorydgraham Sep 30 '19
Everyone is brain dead when it comes to querying :-D
That “hate ORM” phase is when your brain wakes up.
5
u/nutrecht Lead Software Engineer / EU / 20+ YXP Sep 30 '19
Last month I used an ORM framework for the first time (for me it was with the Apache Cayenne framework... there are many out there, everyone will find one that fits their needs).
In a little while you'll be going the other way; have experience with all the problems ORMs cause and just go back to just writing SQL by hand ;)
2
1
u/wildjokers Sep 30 '19
don't really like the native Java HTTP-Request way
Are you talking about the new HttpClient introduced in Java 9? Because that one is pretty nice.
The old way (HttpUrlConnection) was definitely clunky and painful to use.
1
1
u/NominallyImportant Sep 30 '19
I'd have to say for me it's how powerful interfaces really can be, especially when implemented in a well established framework like Spring!
16
u/nebeilg Sep 30 '19
For me it was definitely Generics. It makes it so incredibly easy to have a class be 'dynamic' yet type safe.