-
A Quick Check of Javascript Code Quality - [Javascript]
2009-03-30
Here is the way we used today checking the quality of client side javascript code.
Launch Firefox, access the site under developing, open Firebug console and run the scripts below:
for(var property in window){ console.log(property); }
We get a list of properties directly defined in window instance, which is the place where all global functions and variables exist.Filter out the build in properties and the ones introduced by the external libs, like jQuery, Prototype, and we get all the global functions and variables defined by the team.
Then ask:
- Do we have too many of them and is it a sign of lacking encapsulation?
- Are all of them worth being introduced with global accessibility?
We really got some clues of refactoring, cool!The key is that try object oriented javascript before the plain global functions and variables run out of control.
随机文章:
利用客户端Javascript代码简化Selenium测试 2008-12-23将客户端逻辑封装进Javascript对象,并用Jsunit做单元测试 2008-11-04强调测试的同时不要冷落了设计 2007-11-11
收藏到:Del.icio.us - Do we have too many of them and is it a sign of lacking encapsulation?
<< Implement Object Builder for Testing in a .NET Object Initializer Style | Home | Code Snippet to Log All Events as They Are Triggered >>