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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Ask HN: What would you consider your coding standards?

1 点作者 tech_crawl_超过 9 年前
Just wanted to see if people had different coding standards..

1 comment

Rannath超过 9 年前
Variable name length should match scope. A variable that only does something for three lines can be a single letter (Ex: i). A variable that is (god forbid) global should be nice and long (Ex: global_map_of_all_callback_functions). Everything I control should be readable.<p>Method&#x2F;Class name length should be inversely proportional to usage. If it&#x27;s used everywhere it should be convenient to type (Ex: add). Of course the method&#x2F;Class should still describe what SINGLE responsibility the piece of code has. Remember that the name of the class &amp; parameters is part of the method&#x27;s call signature is many languages (Ex: Registry.add(Person person) could be read as &quot;add person to registry&quot;).<p>Use the generally accepted standards of the community you code in. (Ex: Rust prefers snake_case and SCREAMING_SNAKE_CASE for names)<p>Be consistent.<p>Follow the principles of Clean Code. <a href="https:&#x2F;&#x2F;cleancoders.com&#x2F;" rel="nofollow">https:&#x2F;&#x2F;cleancoders.com&#x2F;</a><p>There&#x27;s more, but that&#x27;s the general thrust of it.