JavaScript Patterns 2.11 Writing Comments
Document all functions, their arguments and return values, and also any interesting or unusual algorithm or technique. Think of the comments as hints to the future readers of the code; the readers need to understand what your code does without reading much more than just the comments and the function and property names. When you have, for example, five or six lines of code performing a specific task, the reader can skip the code details if you provide a one-line description describing the purpose of the code and why it’s there. There’s no hard and fast rule or ratio of comments-to-code; some pieces of code (think regular expressions) may actually require more comments than code.
The most important habit, yet hardest to follow, is to keep the comments up to date.
JavaScript Patterns 2.11 Writing Comments的更多相关文章
- JavaScript Patterns 2.12 Writing API Docs
Free and open source tools for doc generation: the JSDoc Toolkit (http://code.google.com/p/jsdoc-too ...
- JavaScript Patterns 2.1 Writing Maintainable Code
Revisiting the code after some time has passed requires: • Time to relearn and understand the proble ...
- JavaScript Patterns 7.1 Singleton
7.1 Singleton The idea of the singleton pattern is to have only one instance of a specific class. Th ...
- JavaScript Patterns 6.7 Borrowing Methods
Scenario You want to use just the methods you like, without inheriting all the other methods that yo ...
- JavaScript Patterns 6.6 Mix-ins
Loop through arguments and copy every property of every object passed to the function. And the resul ...
- JavaScript Patterns 6.5 Inheritance by Copying Properties
Shallow copy pattern function extend(parent, child) { var i; child = child || {}; for (i in parent) ...
- JavaScript Patterns 6.4 Prototypal Inheritance
No classes involved; Objects inherit from other objects. Use an empty temporary constructor function ...
- JavaScript Patterns 6.3 Klass
Commonalities • There’s a convention on how to name a method, which is to be considered the construc ...
- JavaScript Patterns 6.2 Expected Outcome When Using Classical Inheritance
// the parent constructor function Parent(name) { this.name = name || 'Adam'; } // adding functional ...
随机推荐
- nodejs+express+jade给我baby做个小相册
去年年底迎来了my little star.从此人生多了一个最重要的牵挂.生了宝宝全家人都太忙了.最近宝宝稍微大点了,终于有空可以研究下技术了.这是14年第一帖.废话不多了.开始吧 1.安装NTVS ...
- 重新想象 Windows 8.1 Store Apps (85) - 警报通知(闹钟), Tile 的新特性
[源码下载] 重新想象 Windows 8.1 Store Apps (85) - 警报通知(闹钟), Tile 的新特性 作者:webabcd 介绍重新想象 Windows 8.1 Store Ap ...
- MySQL备份与恢复
1.通过mysqldump命令进行数据备份 mysql数据库的备份采用直接打包数据库文件夹(注:InnoDB引擎不支持直接拷贝数据文件备份数据库,由于使用InnoDB引擎的库或表是不能使用此种方式): ...
- mysql学习笔记 第八天
where,group by,having重新详解 where的用法: where与in的配合使用,in(值1,值2,...)表示结果在值1,值2,...其中任何一个. 聚合函数和group by的用 ...
- ExecutorService常用方法和newFixedThreadPool创建固定大小的线程池
1.ExecutorService: 是一个接口,继承了Executor: public interface ExecutorService extends Executor { } 2.Execut ...
- PHP学习笔记:keditor的使用
keditor时一个免费的开源编辑器,很多公司在使用(百度编辑器也不错).最近为了做一个客户信息管理系统,在发送邮件模块用到这个编辑器,也算学习一下新的东西. 第一步:下载编辑器 到它的官网下载:ht ...
- CentOS6.5 FTP配置
一:安装vsftpd 查看是否已经安装vsftpd rpm -qa | grep vsftpd 如果没有,就安装,并设置开机启动 yum -y install vsftpd chkconfig vsf ...
- tomcat学习笔记一:安装和配置
安装 配置环境: win7 + centos7虚拟机 安装步骤: 到http://tomcat.apache.org/下载最新的tomcat安装包(8.0.24) 移到对应的目录并解压 安装问题: 安 ...
- CentOS6.5 安装Zookeeper集群
1.下载解压 2.配置环境变量:vi ~/.bashrc 或者 vi /etc/profile [hadoopuser@Linux01 ~]$ vi ~/.bashrc # zookeeper ...
- JavaScript Array(数组)对象
一,定义数组 数组对象用来在单独的变量名中存储一系列的值. 创建 Array 对象的语法: new Array(); new Array(size); new Array(element0, elem ...