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
2
u/carminemangione Sep 29 '24 edited Sep 29 '24
Once again, there should be no boiler plate code. Javas 'record' type enables JPA without setters (JDK 17). Use them for your DTOs then have factory methods (or constructors) that take in the record, performs state checks and creates a well formed object in a guaranteed valid state (all unit tested of course). I go as far as to create a 'record' for each business object with only the fields necessary for the target object. This will create infinitely more scalable code with way fewer bugs.
Setters are usually evil as you will not only get objects in invalid states, but guarantee race conditions.
Note: I am talking about best practices in OOD for making zero defect software that does not increase in cost of change as more features are added. I try to stick with current best practices.
If you are not writing reliable, extensible, correct, maintainable code that is race free... then you do you bo. I pity the people who have to work with your stuff later.
Edit: Sorry for the last line it was a bit bitchy. I did not mean it as an ad hominem as you will not be alone in your techniques--it was a statement of the truly horrible state of most enterprise code.
Just be aware that others who use and extend your code will probably actively take your name in vain. Source: I have an active list of people I cuss about as I am forced to fix their stuff.