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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Takes: Java web framework without static methods or annotations

40 点作者 yegor256a将近 6 年前

9 条评论

saagarjha将近 6 年前
I was reading through one of the linked articles of why the author doesn&#x27;t like using null or static objects:<p><a href="https:&#x2F;&#x2F;www.yegor256.com&#x2F;2014&#x2F;05&#x2F;13&#x2F;why-null-is-bad.html" rel="nofollow">https:&#x2F;&#x2F;www.yegor256.com&#x2F;2014&#x2F;05&#x2F;13&#x2F;why-null-is-bad.html</a><p><a href="https:&#x2F;&#x2F;www.yegor256.com&#x2F;2014&#x2F;05&#x2F;05&#x2F;oop-alternative-to-utility-classes.html" rel="nofollow">https:&#x2F;&#x2F;www.yegor256.com&#x2F;2014&#x2F;05&#x2F;05&#x2F;oop-alternative-to-utili...</a><p>Apparently he replaces null with null objects or throwing exceptions, and creates objects for every static method. Go figure.<p>Actually, there are a few gems:<p>&gt; The Map interface (no offense to its authors) has a design flaw.<p>&gt; It is a good practice to make your code as fragile as possible, letting it break when necessary.<p>&gt; The method is basically asking the object about its… race. Black objects go right while white objects go left. That’s what this instanceof is doing, and that’s what discrimination is all about.
评论 #20268891 未加载
fwilhe将近 6 年前
I don&#x27;t understand why the names are so bad. FtFoo, TkBar, XyBaz. Not pronounceable, meaning not inferable. I like Yegor&#x27;s stuff mostly, but the naming just kills me.
评论 #20268973 未加载
评论 #20271261 未加载
Xorlev将近 6 年前
Not trying to knock the work, but why is no static methods a selling point? How does one do utility classes instead? And do you eschew static factory methods entirely?
评论 #20267856 未加载
评论 #20270521 未加载
评论 #20267984 未加载
评论 #20269030 未加载
评论 #20271089 未加载
评论 #20271109 未加载
kasperni将近 6 年前
So from the OOP Alternative to Utility Classes on the site<p>int max = new Max(10, 5).intValue();<p>over<p>int max = Math.max(10, 5)<p>Yeah, think I am going to pass.
评论 #20268706 未加载
jbverschoor将近 6 年前
So instead of static, you’re using fixed classes. No difference there. What’s next, a classfactory? One inner platform effect coming up!<p>It’s a good exercise though!
lalaithion将近 6 年前
I write very annotation&#x2F;static method heavy Java at work, and I write Haskell for fun at home, and my kneejerk reaction to seeing this code in the &quot;Why are static methods bad&quot; link:<p><pre><code> void transform(File in, File out) { Collection&lt;String&gt; src = new Trimmed( new FileLines(new UnicodeFile(in)) ); Collection&lt;String&gt; dest = new FileLines( new UnicodeFile(out) ); dest.addAll(src); } </code></pre> was &quot;That looks just like Haskell&quot;.
评论 #20267840 未加载
gerbilly将近 6 年前
Ok, so we know the framework does not contain all these supposedly bad things¹, but what does the framework <i>do</i> exactly?<p>1: Reminds me of Golang, which likes to define itself as a set of &#x27;negative liberties&#x27; (No exceptions, no inheritance, no polymorphism, no ...).
评论 #20267892 未加载
评论 #20271259 未加载
saagarjha将近 6 年前
&gt; Not a single public static method<p>main?
评论 #20267868 未加载
评论 #20267863 未加载
评论 #20267829 未加载
评论 #20267834 未加载
评论 #20267810 未加载
ribtoks将近 6 年前
Given style of the code, what Yegor needs is Lisp, but not OOP.