Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Project Lombok vs. Eclipse templates / code generation

Does Project Lombok offer any benefit compared to code templates / code generation in Eclipse? Are there any downsides (apart from including the .jar)?.

like image 776
helpermethod Avatar asked Apr 11 '10 10:04

helpermethod


People also ask

Is it good to use Lombok?

Some Good Practices Lombok is just a tool to make your life easy. It does not provide any assistance or support for clean code. If clean code and design principles are not of importance (trust me it's not that bad as it sounds in most of the cases), then using Lombok to simplify development process is the best option.

Is Lombok good Java?

Lombok is an awesome Java library. It helps to reduce the amount of 'infrastructural code'. You don't need to write constructors, getters, setters, and even builders anymore. All you have to do is to put the proper annotations and the plugin will generate everything for you.

Why do we use Lombok?

Lombok is used to reduce boilerplate code for model/data objects, e.g., it can generate getters and setters for those object automatically by using Lombok annotations. The easiest way is to use the @Data annotation.

How does Project Lombok work?

Project Lombok works by plugging into your build process. Then, it will auto-generate the Java bytecode into your . class files required to implement the desired behavior, based on the annotations you used.


1 Answers

One advantage of Lombok is that once you've annotated a class with, say, the @Data annotation, you never need to regenerate the code when you make changes. For example, if you add a new field, @Data would automatically include that field in the equals, hashCode and toString methods. You'd need to manually make that change when using Eclipse generated methods. Some of the time, you may prefer the manual control but for most cases, I expect not.

like image 72
GaryF Avatar answered Sep 28 '22 04:09

GaryF