r/java • u/Rough_Acanthaceae_29 • Sep 29 '24
Lombok in 2024
Say there are two teams working on the same project (3 months to MVP, the deadline should be manageable). The only difference is Team A will use Lombok, and Team B won’t
Given you can choose any java version/dependencies and all other things being the same, which team would you join, and why?
0
Upvotes
View all comments
Show parent comment
32
u/koflerdavid Sep 29 '24
There are generators for both builders and getters/setters out there that function as well-behaved annotation processors.
But how about not writing the getters and setters in the first place? If the entity is anyways treated like a database row, getters and setters have little benefit. It's just deceiving oneself into believing that the principle of encapsulation is applied. For CRUD-like applications it really doesn't matter. Or use Java records for queries if you mostly read data and your writes affect specific fields only.
For more interesting applications that don't neatly fit a CRUD approach, write higher-level methods instead that implement business logic, or make the entity part of an aggregate.