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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Ask HN: What do you consider to be “Clean Code”?

1 点作者 ludovicianul大约 2 年前
I&#x27;m really curious on different viewpoints for what you consider &quot;Clean Code&quot;. Not clever code, but code that you can decently maintain, extend and understand.<p>(I&#x27;m not referring to the concepts that Robert C.Martin&#x2F;Uncle Bob is preaching - although a significant category of people will consider that to be clean code - but rather in general - couldn&#x27;t find a better naming)

3 条评论

ajuc大约 2 年前
- there&#x27;s unit tests<p>- there&#x27;s integration tests<p>- you can run the code locally and it works<p>- you can send data you control to the system<p>- you can check what the system responds with<p>- you can do all of the above in debug mode and breakpoints actually work<p>- the external dependencies are optional or you can control them too on dev environment without too much hassle<p>If I have all of that - maintenance will be easy, SOLID or no SOLID, functional or OOP or whatever.
warrenm大约 2 年前
My only requirements for &quot;clean code&quot; are the following:<p>- readable (use self-describing functions, names, etc; consistent spacing...)<p>- as little repetition as possible<p>- as efficient (or &quot;clever&quot;) as can be, while not sacrificing the first two bullets<p>-- caveat to the last bullet: using &quot;extra-clever&quot; techniques is acceptable <i>IFF</i>, you <i>very</i> clearly document (in comments, code commits, etc) not only <i>what</i> the code is doing, but <i>why</i> you&#x27;re doing it that way
jleyank大约 2 年前
In a functional sense, clean code is something you can return to in 6+ months and quickly understand the flow. Ideally, it&#x27;s code that <i>somebody else</i> can look at and quickly understand the flow. Lack of cruft, clear naming conventions, yeah, but the logic has to be obvious, too.