4 ms·
Lombok already gives you some of this: - Data objects https://projectlombok.org/features/Data.html https://projectlombok.org/features/Data.html That generate t
by RyanHamilton 10y ago
Lombok already gives you some of this:
- Data objects https://projectlombok.org/features/Data.html https://projectlombok.org/features/Data.html
That generate toString, getters, setters etc as required
- Val for local variables https://projectlombok.org/features/val.html https://projectlombok.org/features/val.html
I don't start a new project without it.
And if you really want stripe down java checkout http://jpad.io/ http://jpad.io/ a little program I made to make running java scripts/snippets extremely easy.
- Roboprog 10y agoFWIW, I did a presentation on Lombok at the local Java user group recently: https://docs.google.com/presentation/d/1XouaIJ5d3CaqEW87Fpup7YTcEQc4ZW3UF3hyrnDgx0M/edit#slide=id.p https://docs.google.com/presentation/d/1XouaIJ5d3CaqEW87Fpup... It's a nice tool.
- Yhippa 10y agoI've seen many different codebases but have never run into Lombok. I really want to use it. Any practical gotchas I need to worry about?
- lmm 10y agoAll your tools need to understand it - not just your IDE but if you're using anything like FindBugs, code coverage reporting, profilers.... I used it for a while but that kind of thing really needs to be a first-class language feature, so I switched to Scala (which has case classes) and haven't looked back.
- scalesolved 10y agoAlmost none, well the only thing that is annoying is that type inference currently won't work within lambdas but otherwise it's great. We use Lombok on all our Java services and have never had an issue (we do about 33million requests a day across these services so they are real battle tested and used code bases). Type inference, automatic builders, removal of getters and setters (@Data will automatically add getters and setters to the fields of a class) and (@Value will make the immutable version). I would never work in Java these days without being able to use Java 8/Lombok/Javaslang/Guava.
- twic 10y agoThe gotcha is that Lombok thinks classes should be structs, and will try to persuade you of that too. A fundamental plank of good object-oriented design - which i admit that i rarely see or even practice - is information hiding. Lombok rips that up and burns it. And that may give you a warm feeling for a while, but at some point, you're going to fall through the floor.
- Roboprog 10y agoMost java shops create a lot of "do nothing" scut work "beans". If that's what much of the work you are forced to do is, make short work of it. Lombok of course doesn't help much for classes with "Actual Work" (TM) in them, but that's OK. Was there something more subtle that I'm missing? (quite possible)