Maintainable JavaScript(编写可维护的JavaScript) PART I Style Guidelines
“Programs are meant to be read by humans and only incidentally( 顺便;偶然地;附带地) for computers to execute.” —Donald Knuth
When a team is brought together(被放在一起) for the first time, everyone brings with them their own ideas about how code should be written. After all, each team member comes from a different background. Some may come from one-man shops where they could do whatever they wanted; others may have been on different teams that had particular ways of doing things that they liked (or hated). Everyone has an opinion about how code should be written, and it usually falls in line with(fall in line with 同意) how that individual would personally write it. Establishing style guidelines should always come as early in the process as possible.
The terms “style guidelines” and “code conventions” are often used interchangeably. Style guidelines are a type of code convention aimed at the layout of code within a file. Code conventions can also include programming practices, file and directory layout, and commenting. This book is actually a collection and discussion of code conventions for JavaScript.
Why Style Guidelines?
Figuring out style guidelines is a process that typically takes longer than it should.Everyone has an opinion and, when you’re going to be spending eight hours a day writing code, all programmers want to do so in a way that is comfortable to them. It takes some compromise within the team and a strong leader to move the conversation forward. Once established, style guidelines allow the team to work at a much higher level, because all code looks the same.
Having all code look the same is incredibly important on a team, because it allows:
• Any developer to work on any file regardless of(不管) who wrote it. There’s no need to spend time reformatting or deciphering the logic of the file, because it looks the same as everything else. If you’ve ever opened a file and immediately fixed all the indentation before starting your work, you can understand the time savings consistency provides when working on a large project.
• Errors become more obvious. If all code looks the same, and you come across some code that doesn’t, you’ve likely found a problem.
It’s no wonder that large companies around the world have published style guidelines either internally or publicly.
Style guidelines are a personal thing and must be developed within a team to be effective. This section of the book lists recommended focus areas for the development of your JavaScript code conventions. In some cases, it’s impossible to tell you that one guideline is better than another, because some are just a matter of preference. Rather than trying to force my preferences upon you, this chapter highlights important aspects that should be covered in your style guidelines. My personal code style guidelines for JavaScript are included in Appendix A.
Maintainable JavaScript(编写可维护的JavaScript) PART I Style Guidelines的更多相关文章
- 《编写可维护的JavaScript》之编程实践
最近读完<编写可维护的JavaScript>,让我受益匪浅,它指明了编码过程中,需要注意的方方面面,在团队协作中特别有用,可维护性是一个非常大的话题,这本书是一个不错的起点. 本书虽短,却 ...
- 编写可维护的Javascript读书笔记
写在前面:之前硬着头皮参加了java方面的编程规范培训,收货良多,工作半年有余的时候,总算感觉到一丝丝Coding之美,以及造轮子的乐趣,以至于后面开发新功能的时候,在Coding style方面花了 ...
- 《编写可维护的javascript》读书笔记(中)——编程实践
上篇读书笔记系列之:<编写可维护的javascript>读书笔记(上) 上篇说的是编程风格,记录的都是最重要的点,不讲废话,写的比较简洁,而本篇将加入一些实例,因为那样比较容易说明问题. ...
- 《编写可维护的javascript》读书笔记(上)
最近在读<编写可维护的javascript>这本书,为了加深记忆,简单做个笔记,同时也让没有读过的同学有一个大概的了解. 一.编程风格 程序是写给人读的,所以一个团队的编程风格要保持一致. ...
- 编写可维护的JavaScript 收纳架
如果你看过Nicolas C.Zakas写过的任何作品,你必须承认他是个不折不扣的天才.也只有天才级的才能写出<JavaScript高级程序设计>让所有的前端攻城师人手一本.Nicolas ...
- 【读书笔记】读《编写可维护的JavaScript》 - 编程实践(第二部分)
本书的第二个部分总结了有关编程实践相关的内容,每一个章节都非常不错,捡取了其中5个章节的内容.对大家组织高维护性的代码具有辅导作用. 5个章节如下—— 一.UI层的松耦合 二.避免使用全局变量 三.事 ...
- 编写可维护的JavaScript之编程风格
在团队中只有每个人的编程风格一致,大家才能方便的互相看懂和维护对方的代码. 1. 层级缩进 对于层级缩进目前有两种主张:1)使用制表符这种方法有两种好处,第一,制表符和缩进层级之间是一一对应关系,符合 ...
- 《编写可维护的JavaScript》 笔记
<编写可维护的JavaScript> 笔记 我的github iSAM2016 概述 本书的一开始介绍了大量的编码规范,并且给出了最佳和错误的范例,大部分在网上的编码规范看过,就不在赘述 ...
- 编写可维护的JavaScript代码(部分)
平时使用的时VS来进行代码的书写,VS会自动的将代码格式化,所有写了这么久的JS代码,也没有注意到这些点.看了<编写可维护的javascript代码>之后,做了些笔记. var resul ...
随机推荐
- stdafx.h的作用以及原理
stdafx.h VC工程里面经常见到stdafx.h这个头文件,以前也没有特别注意,但是这个文件用不好经常会出错,所以就GOOGLE了一下,总算是弄清楚了... stdafx的英文全称为:Stand ...
- H5动画优化之路
H5动画60fps之路 在移动端,和Native相比,H5一直都被人吐槽性能差,尤其是在动画方面. 谈到整个Web app的生命周期,一般分为四个部分: 加载 等待用户 响应用户 动画 一般情况下,首 ...
- js 字符串扩展
<script type="text/javascript" language="javascript"> String.prototype.tri ...
- JAVA File常用的API介绍
package coreJava; import java.io.File; import java.io.IOException; public class FileDemo { public st ...
- HTTP错误代码详细介绍
HTTP 400 - 请求无效 HTTP 401.1 - 未授权:登录失败 HTTP 401.2 - 未授权:服务器配置问题导致登录失败 HTTP 401.3 - ACL 禁止访问资源 HTTP 40 ...
- centos 5.x 升级openssl
今日想在centos 5.2上面安装mysql 5.5.37,在make的时候提示: Linking C shared module adt_null.so [ 65%] Built target a ...
- OCR识别流程
1.图像输入.预处理:图像输入:对于不同的图像格式,有着不同的存储格式,不同的压缩方式.预处理:主要包括二值化,噪声去除,倾斜较正等2.二值化:对摄像头拍摄的图片,大多数是彩色图像,彩色图像所含信息量 ...
- oracle database resident connection pooling(驻留连接池)
oracle在11g中引入了database resident connection pooling(DRCP).在此之前,我们可以使用dedicated 或者share 方式来链接数据库,dedic ...
- JNI编程(二) —— 让C++和Java相互调用(2)
3.getRamdomOrder() 这个方法会从backend得到一个随机的Order对象(抱歉这里“Random”拼错了),然后再调用java中相应的通知方法来通知foreground.getRa ...
- VJP1218数字游戏(环形DP)
链接 数据比较小 直接爆了 5重 枚举断开的琏 dp[i][j][k] (i-j)区间为第k段 dp[i][j][k] = min(dp[i][j][k],dp[g][i-1][k-1]*s[i][j ...