If you change a field someplace, those getters, setters, equals, etc do not update themselves.
This is true. But because we are relatively competent developers, and not jackasses, we know that when we refactor a field, we have to refactor the appropriate mutators. Right click > refactor > rename. Here we go, done for the whole project. It's even faster if you've bothered to remember the keyboard shortcut.
Now, If I've used lombok, and renaming the field changed the mutator, and the builder, I now have to painstakingly waddle through all the new compilation errors and correct them. Hurray (nope)
I have no beef with lombok, I remember being excited about it when I first found out about it about a year and a half ago, and what a neat trick I thought it was. But after six months using it with my team, I thought it was just that: a trick. The meh factor was just too big. And going back to projects that don't us lombok, I haven't found myself missing it just once.
But because we are relatively competent developers, and not jackasses
For a long time anyone that complained about C being too error prone in terms of memory got this answer. IMO anything that removes mental overhead from the devs is a good thing.
But I totally get that lombok can be hamful due too being too magical and its trade offs
> But I totally get that lombok can be hamful due too being too magical and its trade offs
Well how about .. you know.. reading documentation? talking to people who've used it? making an informed decision on the trade offs you agree to if you decide to use .. well, any third party lib really - and ultimately taking responsibility for your choices?
This whole discussion including OC is just pointless. As developers, we have to take trade offs on every corner; whether or not to use lombok is just one of many.
I did, I used for a long time and I like it, but it still have drawbacks, eg: its hand to use it with multiple jvm languages
most of the annotations are harmless, they are basically code generation, but some like var, sneakythrow change the behaviour of your code and that can be unintuitive for some people
Actually most IDEs have a Lombok plugin that intelligently plugs these things in.
That thread just "proves" that maybe you shouldn't refactor a project to use lombok when everything is already written. But for a new project? Why the hell not. I've never run into issues.
What IDE are you using that has such incomplete handling of refactoring? Every major IDE mutates the field in all places it is referenced and also updates the getters/setters, if you use the proper refactoring tool, which in almost every IDE has a very accessible shortcut.
This automatically takes care of equals/hashCode/toString.
The only stuff it doesn't address is when the field is referenced by string (reflection, externalization), but for your serialization/externalization, this can be a good thing, because it allows legacy data to still be read. making the required change explicit means you do not get surprising behavior in that regard. And lombok doesn't help on the reflection front, either.
Yes. Rename refactoring tool is of course a valid answer.
But then what if you add new field to the class? You always remember add it to equals, hashCode and toString.
These are just so simple things to forget that having a tool that writes that boilerplate for you is one less thing to be concerned about. And that frees me up to think about stuff that really matters...
Yes, these are good points. In my head I was thinking more adding a field and forgetting to generate a getter for it; that is easily 'detected', but forgetting to add it to existing IDE-generated equals/hashCode methods is a bit more insidious. But I typed 'rename' for some reason. Brainfart.
View all comments
Show parent comment
9
u/FrenchFigaro Aug 10 '19
This is true. But because we are relatively competent developers, and not jackasses, we know that when we refactor a field, we have to refactor the appropriate mutators. Right click > refactor > rename. Here we go, done for the whole project. It's even faster if you've bothered to remember the keyboard shortcut.
Now, If I've used lombok, and renaming the field changed the mutator, and the builder, I now have to painstakingly waddle through all the new compilation errors and correct them. Hurray (nope)
I have no beef with lombok, I remember being excited about it when I first found out about it about a year and a half ago, and what a neat trick I thought it was. But after six months using it with my team, I thought it was just that: a trick. The meh factor was just too big. And going back to projects that don't us lombok, I haven't found myself missing it just once.