Returning to Java after 2.5 years

Dinanjana Gunaratne
2 min readJun 26, 2022

I am working on a Java project after 2+ years. So much has changed

Java has been around forever I guess. There have been many instances I have switched back and forth between Js and Java. But this time around things are much much different
Lombok
Developers are extensively using Lombok. I mean it is a lot. Lombok provides you with few annotations which actually reduces loads of boilerplate codes. No setters or getters, no constructors, no @autowired annotation these are a few things you will be adding less to your code with Lombok

No “@Autowired”
Word is auto wiring dependencies directly on fields from the spring container make testing harder. So bye-bye @Autowired for now. Instead, add dependencies through constructor injection. And you can add some syntactic sugar with Lombok

No null checks, hello optionals (maybe goodbye NullpointerException)
Well, we are no longer adding conditions with “something != null” Those are the days of the past. We have Optionals now. With optionals you can wrap your objects so that consumers by design ask to handle situations where the object is not present. It is a very useful interface.

Hello local syntax, var x = ….
While we are busy making Js look more like Java, folks at Oracle had other ideas. They are making Java look more like Js. Now we can refer to local variables without a type definition. We can declare variables with an initializer with “var”.

OutOfMemory with No op garbage collector
It can be a pain in the ass to simulate an OOM error in previous versions of Java. But with Java 11, you now can opt to run your application with a no op garbage collector which will not clean your Jvm’s memory.

Don't like Java, say hello to Kotlin
Kotlin was around for a while and was used mainly on Android development. But now Kotlin has seeped into backend development due to ease of adaptation and much cleaner code it produces. Also, you can adopt functional programming easily with Kotlin compared to Java.

--

--

Dinanjana Gunaratne

Software engineer in the making. I blog tech and life experiences here. You’re in for a mix bag