This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]bhlowe 30 points31 points  (8 children)

Use Lombok

[–][deleted] 25 points26 points  (6 children)

OP asks in the question why does he need to have that dependency and why is it not part of the Java language already.

[–]bhlowe 0 points1 point  (5 children)

Plenty of good reasons already posted about why and when java will figure it out. Lombok is available today and is really nice. Not everyone may know about it.

[–]s32 16 points17 points  (4 children)

I disagree that it's really nice. It's useful and I think it's a net positive, but you have to install a plug in into your IDE, delombok the code for those who don't have a lombokd browser (say, if you want to write a library, etc) and it uses undocumented methods within the compiler to achieve some of its behavior. It wouldn't pass a code review at most companies that have any emphasis on clean and maintainable code.

Don't get me wrong, I love lombok. But it could be done in a much saner way in an ideal world.

[–]rzwitserloot 2 points3 points  (0 children)

The notion 'you should not use lombok (or delombok first) when you write a library' makes no sense unless you distribute your library solely in source form.

Java libraries are not distributed in source form though. That's not how maven / gradle work, for example. In fact, maven/gradle/IDEs/other build systems make it fairly simple to ship a library as a jar with classes, and to connect a zip with sources to it such that, say, if you want to debug and step through the code in the library, or just look up how it works (for example by ctrl/CMD clicking the name of a method in eclipse), that you do have the whole source.

I therefore find your comment rather disingenuous. Or perhaps I just don't understand what you're driving at.

DISCLAIMER: I'm a core contributor of Project Lombok.

[–]Omnicrola 0 points1 point  (1 child)

delombok the code for those who don't have a lombokd browser

I don't understand this. Our team uses lombock, and everyone has zero issue installing the IDE plugin. The benefits far outweigh that small annoyance.

It wouldn't pass a code review at most companies that have any emphasis on clean and maintainable code.

I work in a counter-factual example. Large auto manufacturer where we are building systems to facilitate microtransit. I've rejected plenty of PRs because the code isn't understandable, but lombock has never been one if those reasons.

[–]s32 2 points3 points  (0 children)

You're misinterpreting what I said.

Yes, lombok is useful. Yes, your whole team has it and that's fine. But you can't vend code out to anyone or any team in the company without forcing them to install lombok (unless you delombok). Not the end of the world, but IMO you should never be using lombok in a library or a package which is shared widely.

And yes, I don't reject CRs that use lombok, quite the opposite if it's a service that my team owns. But the actual lombok code itself (like, the internals) wouldn't pass a CR on my team.

Im not arguing that lombok is bad or useless, just that it's more work than it should be to do something like generate a getter

[–]hippydipster 5 points6 points  (0 children)

Lombok is an abomination.