<story><title>Making Lenses Practical in Java</title><url>https://chriskiehl.com/article/practical-lenses</url></story><parent_chain><item><author>fedeb95</author><text>I don&amp;#x27;t agree on the fact that lombok has brought us out of the dark ages. We used to use it, but it has some drawbacks. One of them, it&amp;#x27;s an additional dependency. This, for a simple thing such as pojo, seems a bit overkill to me. The additional amount of time used to write some cose isn&amp;#x27;t worth the risk of additional bugs hidden in having one more dependency.</text></item></parent_chain><comment><author>misja111</author><text>With Lombok I always felt that it was trying to fix a symptom while it ignored the underlying problem.
If you don&amp;#x27;t like to write out getters and setters in your code, then consider not to implement them at all. Just use value classes with public fields. Or nowadays you can also use records.&lt;p&gt;Some people use the argument that the advantage of getters&amp;#x2F;setters is, that you can add custom logic to them. But IMO that is an antipattern. And even more so if you then hide that enriched setter or getter using Lombok. Code should indicate to the readers what is doing, it shouldn&amp;#x27;t try to hide stuff that could be important.</text></comment>
<story><title>Making Lenses Practical in Java</title><url>https://chriskiehl.com/article/practical-lenses</url></story><parent_chain><item><author>fedeb95</author><text>I don&amp;#x27;t agree on the fact that lombok has brought us out of the dark ages. We used to use it, but it has some drawbacks. One of them, it&amp;#x27;s an additional dependency. This, for a simple thing such as pojo, seems a bit overkill to me. The additional amount of time used to write some cose isn&amp;#x27;t worth the risk of additional bugs hidden in having one more dependency.</text></item></parent_chain><comment><author>jillesvangurp</author><text>I never particularly liked Lombok either but I do appreciate what it does. Which is to remove a lot of boilerplate code related to setters, getters, hashcode, and equals functions, builder classes, etc. Writing that kind of boiler plate manually increases the likelihood of bugs, inconsistencies and allows other weirdness to creep into your code base. Also it&amp;#x27;s rather stupid work to do.&lt;p&gt;These days, I use Kotlin, which removes the need for Lombok while still being able to play nice with it. The most recent version of Kotlin actually added a compiler plugin for Lombok annotations that makes it easier for people with legacy Java code bases with Lombok to introduce Kotlin to their code bases.&lt;p&gt;Kotlin doesn&amp;#x27;t have direct support for lenses but it is a pretty popular feature with some frameworks. Arrow has an implementation for example. And Arrow is of course inspired by Scala. I&amp;#x27;ve also used the Fritz2 framework for browser UIs. It uses compile time generation of lenses. I think they are a bit of a double edged sword. Looks like a lot of complexity for not a whole lot of gain to me. I like keeping things simple instead. This stuff does have the distinct taste of over engineering to it.</text></comment>