TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Lombok Saved My Ass

69 点作者 tuczi超过 5 年前

12 条评论

lmilcin超过 5 年前
While I can understand why somebody would want to use Lombok, this is actually very misguided.<p>If you want to program in better language, just go and use better language.<p>The most important strength of Java and basically the only reason it is being used is that the code is simple to understand (simplistic!), everything is easily trace-able and debuggable and that you get fantastic tools that know everything about code and can provide you safe operations on huge code bases (refactoring, finding usages, tracing and understanding code paths, etc.)<p>Lombok and new Java features decrease reliability of tools removing Java&#x27;s biggest strength.
评论 #21555940 未加载
评论 #21556940 未加载
评论 #21556058 未加载
评论 #21556524 未加载
评论 #21556758 未加载
buremba超过 5 年前
While I tried to use Lombok in Java 8, it never felt safe. Even if I enabled the integration with the IDE, it magically patches my code under the hood so it wasn&#x27;t easy for me to catch the bugs introduced by Lombok.<p>&gt; There is little gotcha when using Java’s try-with-resource syntax. The resource has to implement AutoCloseable interface, so the compiler can use void close() method for closing a resource. Lombok’s @Cleanup, it doesn’t have to implement this interface. The resource just needs to have some closing method which by default is void close() (but you can specify your own method name responsible for closing resource).<p>Specifically, I don&#x27;t agree with this approach in a compiled language like Java. We need to have a standard writing code in Java and AutoCloseable is the way to go. If the library doesn&#x27;t support it, just create a proxy class and implement the interface there. It may be a bit verbose (we switched to Kotlin later on) but it will be much easier to catch the bugs. I don&#x27;t want to spend 4 hours trying to find the root cause of a strange bug in favor of writing less code.
评论 #21555521 未加载
contingencies超过 5 年前
Relative to toponym: a few years ago I got bitten by an unidentified creature on the beach in Lombok and nearly died of asphyxiation due to a severe histamine reaction and the length of time it took to get to a hospital. Really severe .. said my goodbyes to my wife. Never had anything similar in life before or since. Luckily we did reach hospital with a couple of minutes to spare and the local hospital sorted it pronto (oxygen and loads of antihistimines). The cost was minimal. Life really has its ups and downs... too many to care about Java libraries :)
maxpert超过 5 年前
So I&#x27;ve my self used Lombok but I&#x27;ve been using Kotlin lately. IMHO Kotlin if far far superior in terms of how it provides appropriate constructs that are patches to a stale language (hopefully new release cycle fixes it).<p>So far I&#x27;ve observed with libraries like Lombok there is a smaller community (compared to language community) that vets the idea; and the features are opinionated to that particular community. Which results into fragmentation; just as example <a href="https:&#x2F;&#x2F;immutables.github.io&#x2F;" rel="nofollow">https:&#x2F;&#x2F;immutables.github.io&#x2F;</a> and <a href="https:&#x2F;&#x2F;github.com&#x2F;google&#x2F;auto" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;google&#x2F;auto</a> are two libraries providing features like factories and immutable value classes. Then you get articles like <a href="https:&#x2F;&#x2F;codeburst.io&#x2F;lombok-autovalue-and-immutables-or-how-to-write-less-and-better-code-returns-2b2e9273f877" rel="nofollow">https:&#x2F;&#x2F;codeburst.io&#x2F;lombok-autovalue-and-immutables-or-how-...</a> for improving your code.<p>This in my opinion doesn&#x27;t hurt as long as you are a small company. But when your code is going to be used across teams with different opinions, and language doesn&#x27;t enforce a single way to define construct these kind of byte-code mangling ideas fall apart. I&#x27;ve personally people complain about Lombok and they hate it every bit. Doing these constructs at language level removes debate, and unifies how people in larger community. I hope newer versions of Java move fast enough to make something simple like `@Cleanup` a thing of past. I will highly encourage everyone to try Kotlin too; it&#x27;s almost transparent drop-in with better syntax.
sverhagen超过 5 年前
The irony of people telling me that they don&#x27;t appreciate Spring or Hibernate for the magic behind the annotations that they don&#x27;t understand, to then turn around and drag in Lombok. Also, if you are telling me you don&#x27;t like to write getters and setters, does that mean you are not using an IDE? _Sure_, it&#x27;s a little cumbersome to write them, but not a lot?
评论 #21556922 未加载
marktangotango超过 5 年前
Lombok certainly saved my wrists and hands from repetitive stress injury over the years. Manually typing “effective java chapter 1” immutable object implementations can be truly excruciating.
hn23超过 5 年前
So you introduce a new library that does &quot;magic&quot; instead of using one more line? To me this is the opposite of good code. Let alone that the given example would probably live in some library code anyway.
评论 #21556932 未加载
评论 #21557185 未加载
jmartrican超过 5 年前
There is a problem with JaCoCo, a Java code coverage utility, and try-with-resources. It looks like the try-with-resources creates byte code branches that are unreachable. In the JaCoCo report the try-with-resources line shows up with 4 or 8 branches (I forget which) and most of them are not reachable. That is to say, no matter what kind of unit tests you create (essentially there are two, a test where the code throws and a test where the code does not throw) you can not hit all the possible branches that JaCoCo detects.<p>This caused a problem for me because we would write very lean code with low cyclomatic complexity and having these missed branches would screw up our code coverage numbers, causing us to miss our standards. I would just do it the old way, with the finally. I wish I knew about this @CleanUp. For some reason a lot of code i am writing nowadays does not have me messing with streams directly, but when it comes up again I will use this annotation.
评论 #21556584 未加载
hombre_fatal超过 5 年前
<p><pre><code> OutputStream out = new BarOutputStream(); in.transferTo(out); if (out != null) ... </code></pre> Can someone explain how `out` could possibly be null here?
评论 #21556598 未加载
评论 #21557045 未加载
dehrmann超过 5 年前
I&#x27;ve had better luck with patterns that take lambdas (and internally do the try-close) because they&#x27;re impossible for users to screw up.
swrobel超过 5 年前
I was really hoping this was about the Indonesian island
评论 #21556781 未加载
评论 #21556560 未加载
mark_l_watson超过 5 年前
I used Lombok many years ago, but stopped. Modern Lompoc, with tools like delomboc to generate plain Java source code, and better tooling support beyond Eclipse makes Lompoc look pretty good now (if I still used Java). Cool project.
评论 #21555295 未加载