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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Public Static Is Harmful

1 点作者 divyekapoor超过 3 年前

3 条评论

galaxyLogic超过 3 年前
I we don&#x27;t need public static methods then why would we need private static methods either? So, no static methods at all?<p>The reason to define a public static method is it serves as a simple entry-point to the functionality of your class.<p>And what is a constructor if not syntactic sugar for a &quot;static method&quot;, which creates and returns an instance?<p>I also don&#x27;t see the point about &#x27;static coupling&quot;. The class whose static method you are calling could come as an argument, so it would not be static coupling after all?
评论 #30351352 未加载
drost超过 3 年前
&gt; Every public static method can trivially be replaced with a non-static implementation at the cost of a single stack pointer bump.<p>What about static factory methods?
评论 #30351292 未加载
divyekapoor超过 3 年前
private static is fine. Just don&#x27;t use public static - it leads to virulent refactors and brittle dependencies.