代码是针对计算机还是针对人员? [英] Is Code For Computers or for People?

查看:109
本文介绍了代码是针对计算机还是针对人员?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最终,代码最终被编译为最终的CPU指令。但是,代码(以我的拙见)是供人类阅读,更新和交互的。这使我得出以下观察结果:

Ultimately, code compiles down (eventually) into instructions for a CPU. Code, however, (in my humble opinion) is for human beings to read, update, and interact with. This leads me to the following observation:

其他工程师无法读取的代码(即使其功能正常)也是错误的代码。

牢记这一点,该程序员可以做什么以使代码更容易被人阅读?

With that in mind, what can this programmer do to make code more easily read by humans?


  • 命名约定? (Joel在这方面有很多话要说)

  • Naming Conventions? (Joel has a fair amount to say on that one)

代码结构/布局? (请出于对上帝的爱,不要参与 {安置辩论)

Code Structure/Layout? (please, for the love of god, don't get into the { placement debate)

短语? (是否有可能编写看起来更像英语的代码)

Phrasing? (Is it possible to write code that looks more like the English language)

除了< a href = http://www.joelonsoftware.com/articles/Wrong.html rel = noreferrer>乔尔。

推荐答案


任何傻瓜都可以编写
计算机可以理解的代码。好的
程序员编写了人类可以理解的代码。 -Martin Fowler,重构:改进现有代码的设计

但是自己已经得出了这个结论,足以说这是一个巨大的话题。您将无法获得一个答案。使您的代码可维护不仅限于编码样式,还涉及您的总体设计以及构造过程。以下是此网站上的一些标签,其中几乎所有的问题和答案都会影响该主题:

But since you've already reached that conclusion on your own, suffice to say that this is a huge topic. It's not something you'll be able to get a single answer on. Making your code maintainable is not limited to coding style, but also involves your overall design as well as your construction process. Here's some tags on this site where pretty much all the questions and answers will impinge on this topic:

  • coding-style
  • best-practices
  • refactoring

这篇关于代码是针对计算机还是针对人员?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆