4 ms·
Lombok should not be touched, esp. since records have been available. Morealso, lombok is just a sugar coating during compilation time. Even before records, ju
by xxs 3y ago
Lombok should not be touched, esp. since records have been available. Morealso, lombok is just a sugar coating during compilation time.
Even before records, just use public final fields, and be done with the getter/setter nonsense. (IDEs do a good job of offering options for toString(), and c-tors)
Personally, I consider lombok one of the better anti-patterns widely used.
- javanonymous 3y agoLombok can be used for more than just getters/setters. I personally use the @Builder annotation on records with more than 3-4 fields. I find it much more readable than a long list of arguments to the constructor. It also makes it easy to return a copy of the record where only a few fields have changed: var r = book.toBuilder() .lastUpdated(now) .title("...") .build() I also use other annotations, but I could work without them if a future version of Java provides a builder-like pattern (or named arguments)
- bafe 3y agoThis design note could be of interest: https://github.com/openjdk/amber-docs/blob/master/eg-drafts/reconstruction-records-and-classes.md https://github.com/openjdk/amber-docs/blob/master/eg-drafts/...
- jmaker 3y agoTotally, and the With annotation is a bliss. Hope to have it at a syntax level someday, just like in Kotlin. In addition, you can decompile Lombok annotations straight into your code proper and change what you need, Builder methods for validation, say. Lombok is great for DX, especially if you have experience with more recent languages.
- ImprobableTruth 3y agoRecords are the way to go, but there are many situations where the ecosystem doesn't work with them e.g. if you're stuck using something like Hibernate.