3 ms·
Yep. I love data classes for the simplicity and utility but pretty soon there are more annotations than java code. In Java I prefer Immutables over Lombok but
by dangets 8y ago
Yep. I love data classes for the simplicity and utility but pretty soon there are more annotations than java code. In Java I prefer Immutables over Lombok but once you add Jackson annotations, customize the Immutables generated code (@Value.Immutable, @Value.Parameter, etc), add some javax.validation (@NotNull, @NotEmpty) it gets very noisy very quickly. And yet it is still better than writing mutable bean classes by hand IMHO.
Switching to / mixing in Kotlin is worth it just for the data classes at this point (and you get some type-level nullability and `val` instead of `final var` to boot).
https://immutables.github.io/ https://immutables.github.io/
- usrusr 8y agoI'd also prefer immutables.org over lombok, because it cleverly gets by without changing the way sourcecode is turned into bytecode. All it ever does is generate additional class files that add the boring stuff. If lombok says "we can have all this awesome stuff if we break the rules a bit", immutables.org answers "we can have almost as much of we don't".
- Rapzid 8y agoI would be nice for any language that supported annotations(TypeScript, C#, python, etc) if we could somehow annotate the same code in different files while maintaining a single source of property truth.. A combination of interfaces and class annotations for combining them could work..
- jcheng 8y agoI don't know if this is what you mean, but Aspect Oriented Programming was a hot topic for a very short period in the early 2000's, especially in the enterprise Java community. Ultimately it didn't seem to find many use cases and the buzz died down pretty quick. https://en.wikipedia.org/wiki/AspectJ https://en.wikipedia.org/wiki/AspectJ
- EmpirePhoenix 8y agoThe hype wave is gone, but if you ever saw @Secured or @Transactional, those are aspects after all.
- guapo 8y agoOr just register the Jackson Java 8 datatypes module. Then you can create a standard immutable class with a constructior, and Jackson's object mapper can then serialize and deserialize. The only catch is that you must add -parameters to your javac args.
- Shawnecy 8y agoThis is what I do. Can attest that it keeps things very clean and lean.