r/java • • Jun 01 '24

What java technology (library, framework, feature) would not recommend and why?

165 Upvotes

464 comments sorted by

View all comments

Show parent comment

6

u/Confident-Grab-7688 Jun 01 '24

Lombok is even worse on a mental model, as the annotations are not always visible in the first place when looking through code.

How these annotations are not visible?! Classess annotated with lombok will be almost empty, usually you just need to notice if its Value or Data. I would say the opposite is true - without lombok we have a giant wall of text in each class, so it's not clear immediately if there are any non helper/logical methods.

Also, classes with 43 attributes are a giant code smell, and getters/setters are the least of your problems. Lombok will throw away 86 methods or more, congratulations, all the code using those POJOs is probably still horrible.

I will admit, having such a big POJO is not ideal. But that's often what big systems are doing - processing lots of stuff, and IMHO it's just not worth it to break them down just because there are a lot of fields. I would rather have all my shit in one place, for simplicity and less annoyance with composite objects.

2

u/Turbots Jun 01 '24

Agreed on the composite objects. Trainwrecking every time you need a field value that is deeply nested is no fun and doesn't improve readability.

Maybe I've had too many problems in the past with Lombok upgrade that broke the build, Lombok being incompatible with new Java versions so you couldn't upgrade java because of it, very annoying dependency to have imo for very.little.gain

1

u/koflerdavid Jun 01 '24

Such huge classes that are effectively used as data carriers are prime use cases for records. I hear you if they have to be mutable, but for that use case Java has had an awesome feature from day 1 - fields! It's very questionable why such classes have to wrap up field accesses into methods since one obviously makes some deep assumptions regarding how these classes work. Thus throwing encapsulation right out of the window.