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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Ask HN: How to learn to give clear, descriptive names to class, methods etc

6 点作者 jackbean大约 14 年前
Its one thing I wish I did better when writing code. The names are either obscure or turn into sentences before I can fully express what they try to do.<p>There probably isn't a surefire way to get better at this and something that must be worked on and cultivated. But any advise pointing the way is appreciated.

3 条评论

cammil大约 14 年前
Much of the problem of naming things is that the name you give them now, is unlikely to be the most appropriate name in the future. For example, your code may change, you may make other similar classes that would be more appropriate with that name, etc.<p>The strategy I use is to iterate naming, just as I would any other aspect of code. You are unlikely to want to do this as often, but if you find your current names are no longer working for you, it might be time for a change.
评论 #2601006 未加载
hcho大约 14 年前
"There are only two hard things in Computer Science: cache invalidation and naming things." Tim Bray<p>My personal approach is to copy shamelessly. Whenever I come accross a very readable piece of code, I add it to my bookmarks. When I am stuck with naming something I go through my bookmarks and somethin inspiring always comes up.
drothlis大约 14 年前
Read "Code Complete".