TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Public Static Is Harmful

1 pointsby divyekapoorover 3 years ago

3 comments

galaxyLogicover 3 years ago
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 未加载
drostover 3 years ago
&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 未加载
divyekapoorover 3 years ago
private static is fine. Just don&#x27;t use public static - it leads to virulent refactors and brittle dependencies.