Lombok is used in the legacy project where I am currently working for since last year. The project is legacy with 10+ years, and POJO/JavaBeans, i.e. @Data
annotated classes, have been widely used for probably 10+ years.
However, since I have been using Lombok for many years in other companies, I just prefer to using the immutable@Value
objects whenever possible. But some of my team members had serialization problems with Jackson in his local IDE, so they seems not like it, and one of them gives the following comments
I usually prefer @Data over @Value because there’s always a good chance that immutability will cause unexpected problems (such as this).
The detail of such as this
problem is only this much from my teammate:
I’m getting complaints about Jackson not being able to deserialize the parameter object (e.g. XXXParamsVO) because of the lack of a proper constructor. And indeed there is no no-args constructor in those classes
I never had any compilation problems in my IDE, so honestly imo this sounds absurd. Not only one book recommend the use of immutable objects, a typical one is in Effect Java, where there is an item
Minimize mutability
and in that section, it was told clearly why immutable objects should be used.
I would like to ask any more experienced developers opinions about this. Does the "minimize mutability" really not make sense?