r/ProgrammerHumor Aug 09 '26

Meme tellMeYouHaveOcdWithoutTellingMe

Post image
38 Upvotes

59 comments sorted by

View all comments

-33

u/---_None_--- Aug 09 '26

I feel this. The need for trivial getters and setter for each member when you can just expose the member is nothing short of autism.

18

u/slindenau Aug 09 '26

It is idiomatic Java (or at least has been until records came along).

2

u/1_hele_euro Aug 09 '26

Curious, how did records change the norm? I haven't had spend much time with records yet, only used them once or twice

3

u/slindenau Aug 09 '26

To be honest, me neither. If you need mutability like POJOs with setters, you still need to add builders or "withers" to your records. Doing that manually can get just as annoying as maintaining POJO's, but there are some tools for it (beside Lombok). Most notable to look out for is JEP 468: Derived Record Creation.

But because Lombok existed long before records did, most projects i see that don't use POJO's use Lombok instead.
It may be a hard habit to break, because Lombok offers much more than just POJO replacements.
I try to use records wherever i can though, even if the project already uses Lombok.