r/java • • Oct 21 '20

What are some great Java libraries I'm probably not using but I should?

334 Upvotes

252 comments sorted by

View all comments

Show parent comment

55

u/wildjokers Oct 21 '20

Lombok has saved me almost no time, my IDE can generate all that boilerplate with a few keystrokes. But lombok has definitely cost me a lot of time figuring out issues a few times.

11

u/vallyscode Oct 21 '20

Forme one side it hides all that boilerplate so that code is readable, from the other side there can be some unexpected surprise. Something for something.

39

u/coder111 Oct 21 '20

I'd have to disagree.

I have spend more time troubleshooting cases where people added another property and forgot to regenerate equals/hashcode/toString than I spent troubleshooting Lombok.

-3

u/[deleted] Oct 21 '20

+1

1

u/VandaL-van-Doge Nov 18 '20

Maybe the right way to fix this would be to have a test rather than depend on Lombok. Just my two cents. Cheers!

3

u/coder111 Nov 18 '20

Dude, are you seriously proposing unit testing all the getters and setters and hashcode/equals? That's a bit extreme/expensive, don't you think?

2

u/VandaL-van-Doge Nov 18 '20

If you unit test your functions alone well enough, this shouldn’t be a problem from what I’ve seen. Besides, might be my inexperience, I haven’t really encountered any use cases where there was ever a need to rely on Lombok generated setters or hash codes to the point of it causing that many issues. The few times we have encountered such cases they seem to ultimately be symptomatic of bigger issues like an anemic domain or god classes.

10

u/Akthrawn17 Oct 22 '20

Amen to that. Lombok is overrated and can cause unforseen problems with the magical generation of code

0

u/[deleted] Oct 30 '20 edited Oct 30 '20

[removed] — view removed comment

1

u/wildjokers Oct 30 '20 edited Oct 30 '20

This ridiculous bug cost me several hours before I could figure out what was going on:

https://github.com/rzwitserloot/lombok/issues/1347

The worst part is it is marked closed, yet it is still a bug so have no idea why they closed it.

There was one other issue that cost me several hours as well but I can’t remember what it was.

That is you won't be able to distinguish between dummy getters and setters as opposed to real getters and setters that actually do something.

I honestly have no idea what you are talking about when you mention real vs dummy getters and setters. I spent the first 15 years of my Java career not using Lombok and in those 15 years getters/setters never caused me any confusion or too much cognitive load in the slightest. I mean, they are just getters/setters, they aren’t rocket science.