A Java controversy: Lombok

Ailton Junior
3 min readNov 16, 2021

--

(Leia a versão em Português aqui!)

The year was 2016, I was an intern inside a big company which gives me an opportunity to ingress and build my IT carreer. Working with a Software Architect I was clearly cappable of remember when he presented Lombok to me, some magical annotations that generate “some necessary codes” in the back like: Builder, a Getter and Setter, a full args constructor or an empty constructor.

A lot of articles until now may say Lombok is a good idea, a fast and good practice. Do I really need to use Lombok instead of a two-click IDE code-generation? How about generating getters and setters without thinking and assume, that your class won’t need to be final, I mean an immutable class? Since some devs are not aware of “@Value” annotation.

Lombok is a lazy tool for lazy developers, that what it really is. It does not force you to think about your model objects because you are blessed with @Data annotation . It makes you lose the control of your own code with magic annotations that will generate code you don’t even know if you need. And I’m not saying that based in my singular opinions, I just give myself the opportunity to talk to another developers to collect the maximum information as possible. So, are you saving space from your github repository?

Reasons why some developers don’t like Lombok:

  • More dependency from your IDE: Not saying as a developer I’m not dependent, of course all of we surely are, but depending on Lombok, is it a good choice? Knowing what it gives? A big amount of code generation unnecessarily
  • One more step in Dev’s onboarding: It’s not just clone your repository and simply work. You have to clone your repository and also configure your IDE, else your code won’t compile
  • Tipically going with the flow: It is so common defending on Lombok with the argument that it reduces the verbosity of Java’s language. So, the laziness is an alternative because of it? I’m not sure if the right-way to fix Java’s verbosity is using Lombok. Java IS a verbose language. If you are trying to reduce it with Lombok, are you sure you chose the correct language?
  • Add one more dependency in your project because you are too lazy to do a two-button click: As said before, constructors, getters and setters, all can be generated with your IDE
  • Annotation-based-programming: Great part of Lombok-lovers enjoy using “@Data” annotation. Have you ever heard something like: “Just put @Data and it will generate everything for you”? Or just a “Builder? Use @Builder”?
  • Generation of unused code: You won’t use great part of what was generated by Lombok.

Don’t use Lombok make you work more? Not sure of that, IDE just gives you a lot of options to optimize your work. But, even it makes you work more, know that without lombok, you make your code controlled, since we don’t have unexpected generated code in the backside.

Talk to your company, your manager, your friend, express your arguments and analyze if Lombok will make your code productive, or if it is just a popular tool which was created to help, but instead of it, gives some problems to community code.

Thank God we don’t need to work with Lombok in Kotlin. ¯\_(ツ)_/¯

--

--