Project Lombok

manu3d

Active Member
Contributor
Architecture
I just stumbled upon this article while searching for strategies to reduce boilerplate code in java.

I've been wondering what the more seasoned programmers here think about it. Is that a useful thing? Or one gets used to boilerplate code and it's not so bothersome anymore?
 

synopia

Member
Contributor
Architecture
GUI
This kind of boilerplate code most commonly occurs in cases, you have data transfer objects - objects, that have many fields and very few or (even better!) no business model related code. They are just data structures. In these cases its really useless to generate getter and setter code at all. So the fields are just public and no active or passive code generation is needed at all.

In contrast, a service or system operates on this data. Such classes dont need many fields, because all state information should be stored in the data classes. So there is no need for many getter/setters, too.

To summarize, there may be cases where lombok style frameworks are useful, but right now I dont see this for Terasology (since we have this megacool entity/component thing).

Another approach is used in playframework where each public field and all its access code is modified to private fields + getter/setter access code on the fly (using asm, I guess).
 

Cervator

Org Co-Founder & Project Lead
Contributor
Design
Logistics
SpecOps
TeraMath also uses some really fancy code generation to avoid excess code already. Cool stuff :)
 

msteiger

Active Member
Contributor
World
Architecture
Logistics
Yes, TeraMath uses StringTemplate (from the ANTLR guy) to generate different, but similar Java class based on a common template.

I think that Lombok is quite useful, also in terms of automatic generation of equals/hashcode methods, but I never had a use case at hand where it would really fit. Maybe ORM (i.e. mapping Java objects to database table entries) could be one?
 
Top