Writing Better Javascript

   some of the techniques I use to make my code easier for other   programmers and projects to use.

  dumping useful functions into the utils.js file throughout this book.

   The problem with just dumping functions into a file in this way is that they become hard to manage  and maintain and, as I’ll explain shortly, difficult for others to integrate into their projects.    不利于别人使用,,,,

    I revisit my kitchen-sink file when I have reached a point in a project where the basic
functionality is stable and I have a good feel for the way that different features fit together. At this point,
and not before, I start to rework the code into modules so that it plays nicely with other libraries.

   再看代码,如果基本功能很稳定,并且把不同情况汇合到一起。再找代码重构,和别的库融合

  Once I have tidied up and modularized the code, I begin unit testing    当在模块化代码的时候,开始单元测试

Testing is a very personal
thing, and many testing proselytizers will insist that testing must begin as soon as you start coding

  测试是一个非常个人的事,

Test when it feels right, test until you are happy with your code, and use the
techniques and tools that work for you        测试感觉正确,喜欢自己的代码,并使用一些一具和技术

Managing the Global Namespace

posted @ 2012-07-19 08:33  顺武  阅读(178)  评论(0编辑  收藏  举报