关于javascript:20年老程序员告诉你坚持这20条编程原则让你终身受益

22次阅读

共计 11766 个字符,预计需要花费 30 分钟才能阅读完成。

本文作者是一位有着 20 年编程生涯的骨灰级程序员,从 Basic、C 到 Java、JavaScript,从码农到研究员到 CTO,他始终沉闷在编程的第一线。本文是他 20 年职业生涯总结下来的编程准则。

我从 1999 年就开始了编程生涯,到往年曾经有 20 多年了。我先是从 Basic 开始,很快转到了 Pascal 和 C 语言,而后又学习了面向对象编程语言 Delphi 和 C++。2006 年,我开始应用 Java,2011 年开始应用 JavaScript。我参加过各个行业的软件开发,从机器人、金融科技、医疗到媒体和通信。我还负责过研究员、CTO、TPM(技术产品经理)、老师、零碎架构师和技术负责人,但不管怎样,我始终都在编程。在我参加过的我的项目当中,有些为数百万人提供服务,有些在公布之前就宣告失败。我做过征询参谋,还开办过本人的公司。我在开源我的项目、闭源我的项目和外部开源我的项目上花了很多工夫,从微控制器到挪动利用、桌面利用,再到云服务和无服务器架构。

我把过来 20 年积攒的一些最为重要的编程准则总结如下:

1、不要纠结于开发工具——不论是库、编程语言还是平台。尽可能应用原生的构件。不要扭曲技术,也不要扭曲了问题自身。为要解决的问题抉择适合的工具,否则你要为你所抉择的工具重新安排你的工作。

2、你写的代码不是给机器看的,而是给你的共事和将来的你看的(除非你写的是一次性代码或汇编代码)。写代码的时候要考虑一下高级开发者,他们会把你的代码作为参考。

3、优良的软件是合作开发的后果。高效沟通,进行开放式的合作。信任他人,并让别人也信赖你。尊重别人胜过尊重代码。言传身教,把你的追随者变成领导者。

4、分而治之。为拆散的关注点开发独自的低耦合模块。进行独自的模块测试和集成测试。尽可能依照理论状况测试,同时也要测试到各种边界状况。

5、不要把本人与代码捆绑在一起,要想方法让其他人也能批改你的代码或者增加新的性能,这样你能力更容易脱身去参加其余我的项目,或者去其余公司。不要捆绑本人,否则你很难成长。

6、安全性是分层的,每一层须要进行独自的评估,同时又与整体相干。危险是一个业务决策,与脆弱性和概率有间接的关系。每一个产品或组织都有不同的危险偏好(为了取得更大的收益,他们违心承担风险)。通常这三个关注点之间存在互相抵触:用户体验、安全性和性能。

7、要意识到每一行代码都有其生命周期,它们最终都会死掉。有时候,一些代码会在公布之前就死掉,所以要学会撒手。代码能够分为三种:一种是外围代码,就像汽车的引擎,没有了它,产品就毫无意义;一种是必要的代码,就像是汽车的备胎,平时用得少,但一旦须要,它决定了零碎的成败;一种是增值的代码,就像汽车的杯托,如果有那是再好不过,但如果没有也不会影响产品。

8、不要把你的集体标识融入到代码里,人和代码应该是拆散的。不要把其他人对代码的评估与你本身分割到一起,在评估别人的代码时也要非常审慎。

9、技术债权就像快餐一样,偶然欠下一点技术债权是可承受的,但如果你习惯了这样,它会毁掉你的产品(而且是以让你措手不及的形式)。

10、在寻找解决方案时,请依照这样的优先级进行决策:安全性 > 可用性(可拜访性和用户体验)> 可维护性 > 简略性(开发者体验)> 简洁性(代码量)> 性能。但不能自觉照搬,而是要依据产品的特点进行取舍。你积攒的教训越多,就越是可能在这些因素之间做出衡量。例如,在设计游戏引擎时,性能享有最高的优先级,但在开发银行应用程序时,安全性则最为重要。

11、拷贝粘贴是滋生 bug 的温床。对你所拷贝或导入的货色加以审查,bug 个别会藏身在复杂性中。依赖项简单没有关系,但不能让它存在于代码中。

12、不要只顾着写失常的代码,解决异样的代码也要好好写。让人们明确为什么会产生异样、如何检测到的以及怎么解决。对所有的零碎输出(包含用户输出)进行验证:尽早失败,并尽可能从谬误中复原。咱们要假如用户手里握着一把枪:你致力让用户输出一些其余的货色,而不是让他们的子弹射在你的脑门上。

13、不要应用依赖项,除非应用它们的老本比你本人写代码的成本低很多。因为应用依赖项要导入、保护、解决 bug,在必要的时候还要进行重构,这些都是老本。

14、远离“炒作驱动开发”,但你要去理解它们,做一些尝试。

15、走出舒服区,每天都要学习。把学到的货色分享进去。如果你以巨匠自居,就不是在学习。接触更多的编程语言、技术、文化,放弃一颗好奇心。

16、好代码不须要正文,而优良的代码提供了良好的正文,能够让任何一个原先没有参加代码演进、试错和需要过程的人更容易浏览、批改它。

17、尽量避免应用重载、继承和隐式的智能个性。应用纯函数,它们更容易测试和诊断,否则的话就应用类。实现不同性能的函数要应用不同的名字。

18、在彻底理解问题之前不要急着写代码。花在聆听和理解问题上的工夫通常比花在写代码上的工夫要多。在写代码之前要先理解问题域。问题就像迷宫一样,你要循序渐进,重复进行“编码 – 测试 – 改良”,直到把问题解决为止。

19、不要尝试去解决不存在的问题。不要进行投机性编程。只有在确定代码的确须要具备扩展性之后才让代码具备可扩展性。通常状况下,当代码被扩大之后,你会发现问题会变得与原先认为的不一样了。

20、大家一起开发软件会更加乏味。建设可继续倒退的社区。聆听,激发灵感,学习,分享。

我并不是软件开发方面的权威,但这些都是我一路走来总结进去的准则。我置信,20 年后,这些准则会发生变化,会变得更加成熟。
http://github.com/threebb10/w…
https://github.com/threebb10/…
https://www.github.com/threeb…
http://github.com/threebb10/w…
https://github.com/threebb10/…
https://www.github.com/threeb…
http://github.com/threebb10/w…
https://github.com/threebb10/…
https://www.github.com/threeb…
http://github.com/threebb10/w…
https://github.com/threebb10/…
https://www.github.com/threeb…
http://github.com/threebb10/w…
https://github.com/threebb10/…
https://www.github.com/threeb…
http://github.com/threebb10/w…
https://github.com/threebb10/…
https://www.github.com/threeb…
http://github.com/threebb10/w…
https://github.com/threebb10/…
https://www.github.com/threeb…
http://github.com/threebb10/w…
https://github.com/threebb10/…
https://www.github.com/threeb…
http://github.com/threebb10/w…
https://github.com/threebb10/…
https://www.github.com/threeb…
http://github.com/threebb10/w…
https://github.com/threebb10/…
https://www.github.com/threeb…
http://github.com/threebb10/w…
https://github.com/threebb10/…
https://www.github.com/threeb…
http://github.com/threebb10/w…
https://github.com/threebb10/…
https://www.github.com/threeb…
http://github.com/threebb10/w…
https://github.com/threebb10/…
https://www.github.com/threeb…
http://github.com/threebb10/w…
https://github.com/threebb10/…
https://www.github.com/threeb…
http://github.com/threebb10/w…
https://github.com/threebb10/…
https://www.github.com/threeb…
http://github.com/threebb10/w…
https://github.com/threebb10/…
https://www.github.com/threeb…
http://github.com/threebb10/w…
https://github.com/threebb10/…
https://www.github.com/threeb…
http://github.com/threebb10/w…
https://github.com/threebb10/…
https://www.github.com/threeb…
http://github.com/threebb10/w…
https://github.com/threebb10/…
https://www.github.com/threeb…
http://github.com/threebb10/w…
https://github.com/threebb10/…
https://www.github.com/threeb…
http://github.com/threebb10/w…
https://github.com/threebb10/…
https://www.github.com/threeb…
http://github.com/threebb10/w…
https://github.com/threebb10/…
https://www.github.com/threeb…
http://github.com/threebb10/w…
https://github.com/threebb10/…
https://www.github.com/threeb…
http://github.com/threebb10/w…
https://github.com/threebb10/…
https://www.github.com/threeb…
http://github.com/threebb10/w…
https://github.com/threebb10/…
https://www.github.com/threeb…
http://github.com/threebb10/w…
https://github.com/threebb10/…
https://www.github.com/threeb…
http://github.com/threebb10/w…
https://github.com/threebb10/…
https://www.github.com/threeb…
http://github.com/threebb10/w…
https://github.com/threebb10/…
https://www.github.com/threeb…
http://github.com/threebb10/w…
https://github.com/threebb10/…
https://www.github.com/threeb…
http://github.com/threebb10/w…
https://github.com/threebb10/…
https://www.github.com/threeb…
http://github.com/threebb10/w…
https://github.com/threebb10/…
https://www.github.com/threeb…
http://github.com/threebb10/w…
https://github.com/threebb10/…
https://www.github.com/threeb…
http://github.com/threebb10/w…
https://github.com/threebb10/…
https://www.github.com/threeb…
http://github.com/threebb10/w…
https://github.com/threebb10/…
https://www.github.com/threeb…
http://github.com/threebb10/w…
https://github.com/threebb10/…
https://www.github.com/threeb…
http://github.com/threebb10/w…
https://github.com/threebb10/…
https://www.github.com/threeb…
http://github.com/threebb10/w…
https://github.com/threebb10/…
https://www.github.com/threeb…
http://github.com/threebb10/w…
https://github.com/threebb10/…
https://www.github.com/threeb…
http://github.com/threebb10/w…
https://github.com/threebb10/…
https://www.github.com/threeb…
http://github.com/threebb10/w…
https://github.com/threebb10/…
https://www.github.com/threeb…
http://github.com/threebb10/w…
https://github.com/threebb10/…
https://www.github.com/threeb…
http://github.com/threebb10/w…
https://github.com/threebb10/…
https://www.github.com/threeb…
http://github.com/threebb10/w…
https://github.com/threebb10/…
https://www.github.com/threeb…
http://github.com/threebb10/w…
https://github.com/threebb10/…
https://www.github.com/threeb…
http://github.com/threebb10/w…
https://github.com/threebb10/…
https://www.github.com/threeb…
http://github.com/threebb10/w…
https://github.com/threebb10/…
https://www.github.com/threeb…
http://github.com/threebb10/w…
https://github.com/threebb10/…
https://www.github.com/threeb…
http://github.com/threebb10/w…
https://github.com/threebb10/…
https://www.github.com/threeb…
http://github.com/threebb10/w…
https://github.com/threebb10/…
https://www.github.com/threeb…
http://github.com/threebb10/w…
https://github.com/threebb10/…
https://www.github.com/threeb…
http://github.com/threebb10/w…
https://github.com/threebb10/…
https://www.github.com/threeb…
http://github.com/threebb10/w…
https://github.com/threebb10/…
https://www.github.com/threeb…
http://github.com/threebb10/w…
https://github.com/threebb10/…
https://www.github.com/threeb…
http://github.com/threebb10/w…
https://github.com/threebb10/…
https://www.github.com/threeb…
http://github.com/threebb10/w…
https://github.com/threebb10/…
https://www.github.com/threeb…
http://github.com/threebb10/w…
https://github.com/threebb10/…
https://www.github.com/threeb…
http://github.com/threebb10/w…
https://github.com/threebb10/…
https://www.github.com/threeb…
http://github.com/threebb10/w…
https://github.com/threebb10/…
https://www.github.com/threeb…
http://github.com/threebb10/w…
https://github.com/threebb10/…
https://www.github.com/threeb…
http://github.com/threebb10/w…
https://github.com/threebb10/…
https://www.github.com/threeb…
http://github.com/threebb10/w…
https://github.com/threebb10/…
https://www.github.com/threeb…
http://github.com/threebb10/w…
https://github.com/threebb10/…
https://www.github.com/threeb…
http://github.com/threebb10/w…
https://github.com/threebb10/…
https://www.github.com/threeb…
http://github.com/threebb10/w…
https://github.com/threebb10/…
https://www.github.com/threeb…
http://github.com/threebb10/w…
https://github.com/threebb10/…
https://www.github.com/threeb…
http://github.com/threebb10/w…
https://github.com/threebb10/…
https://www.github.com/threeb…
http://github.com/threebb10/w…
https://github.com/threebb10/…
https://www.github.com/threeb…
http://github.com/threebb10/w…
https://github.com/threebb10/…
https://www.github.com/threeb…
http://github.com/threebb10/w…
https://github.com/threebb10/…
https://www.github.com/threeb…
http://github.com/threebb10/w…
https://github.com/threebb10/…
https://www.github.com/threeb…
http://github.com/threebb10/w…
https://github.com/threebb10/…
https://www.github.com/threeb…
http://github.com/threebb10/w…
https://github.com/threebb10/…
https://www.github.com/threeb…
http://github.com/threebb10/w…
https://github.com/threebb10/…
https://www.github.com/threeb…
http://github.com/threebb10/w…
https://github.com/threebb10/…
https://www.github.com/threeb…
http://github.com/threebb10/w…
https://github.com/threebb10/…
https://www.github.com/threeb…
http://github.com/threebb10/w…
https://github.com/threebb10/…
https://www.github.com/threeb…
http://github.com/threebb10/w…
https://github.com/threebb10/…
https://www.github.com/threeb…
http://github.com/threebb10/w…
https://github.com/threebb10/…
https://www.github.com/threeb…
http://github.com/threebb10/w…
https://github.com/threebb10/…
https://www.github.com/threeb…
http://github.com/threebb10/w…
https://github.com/threebb10/…
https://www.github.com/threeb…
http://github.com/threebb10/w…
https://github.com/threebb10/…
https://www.github.com/threeb…
http://github.com/threebb10/w…
https://github.com/threebb10/…
https://www.github.com/threeb…
http://github.com/threebb10/w…
https://github.com/threebb10/…
https://www.github.com/threeb…
http://github.com/threebb10/w…
https://github.com/threebb10/…
https://www.github.com/threeb…
http://github.com/threebb10/w…
https://github.com/threebb10/…
https://www.github.com/threeb…
http://github.com/threebb10/w…
https://github.com/threebb10/…
https://www.github.com/threeb…
http://github.com/threebb10/w…
https://github.com/threebb10/…
https://www.github.com/threeb…
http://github.com/threebb10/w…
https://github.com/threebb10/…
https://www.github.com/threeb…
http://github.com/threebb10/w…
https://github.com/threebb10/…
https://www.github.com/threeb…
http://github.com/threebb10/w…
https://github.com/threebb10/…
https://www.github.com/threeb…
http://github.com/threebb10/w…
https://github.com/threebb10/…
https://www.github.com/threeb…
http://github.com/threebb10/w…
https://github.com/threebb10/…
https://www.github.com/threeb…
http://github.com/threebb10/w…
https://github.com/threebb10/…
https://www.github.com/threeb…
http://github.com/threebb10/w…
https://github.com/threebb10/…
https://www.github.com/threeb…
http://github.com/threebb10/w…
https://github.com/threebb10/…
https://www.github.com/threeb…
http://github.com/threebb10/w…
https://github.com/threebb10/…
https://www.github.com/threeb…
http://github.com/threebb10/w…
https://github.com/threebb10/…
https://www.github.com/threeb…
http://github.com/threebb10/w…
https://github.com/threebb10/…
https://www.github.com/threeb…
http://github.com/threebb10/w…
https://github.com/threebb10/…
https://www.github.com/threeb…
http://github.com/threebb10/w…

正文完
 0