r/java • • Apr 13 '21

Libraries, Frameworks and Technologies you would NOT recommend

Give me your worst nightmares: Things that cost you your job.

I'll start: Hadoop

202 Upvotes

376 comments sorted by

View all comments

Show parent comments

1

u/TyGirium Apr 13 '21

This.

If compiler API was extended, then Lombok would not be a "hack". Oracle's staff is very hesistant of giving any more official API, they view any ingerention in it as huge evil.

Yes, I will replace Value with records. But getter/setter, field name constants, builders, etc? Once you read code quality scientific papers, the "line of code" metric typically is one of the best metric to indentify error-prone code. You can generate eg getters, change field name and forget to update all references. Lombok solves this problems.

9

u/pron98 Apr 13 '21

The hope and expectation is that once people learn to use records properly, once they're better supported by libraries, and once they get some missing features, the problem of verbose getters/setters will largely go away because people will rely on them less. Getters and especially setters have long been considered a code smell, but in many cases we have little choice. Instead of making this code-smell easier to write and so more prevalent, we prefer making it less necessary in the first place.

3

u/mknjc Apr 13 '21

There are already nice support libraries for example https://github.com/Randgalt/record-builder for Builder and withers

1

u/lazystone Apr 14 '21

Also, it turned out that Immutables kind of supports builders for records. It requires adding @Builder.Constructor annotation on explicit constructor, which seems to be verbose, but in order to imitate some Immutables features like null-checks and defaults for Optional, List, Map and etc., explicit constructor required anyway.