路宁(luning)的博客

    <<  Implement Object Builder for Testing in a .NET Object Initializer Style | Home | Code Snippet to Log All Events as They Are Triggered  >>
  • 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.

     


    随机文章:

    Share DOM Fixtures between JavaScript Unit Tests 2009-12-21
    Code Snippet to Log All Events as They Are Triggered 2009-04-28
    利用客户端Javascript代码简化Selenium测试 2008-12-23
    将客户端逻辑封装进Javascript对象,并用Jsunit做单元测试 2008-11-04
    强调测试的同时不要冷落了设计 2007-11-11

    收藏到:Del.icio.us
    Tag:Javascript Object-Oriented-Javascript
    Cite url:
    luning published this at 18:20:11 | Edit | Continue This Topic | Forward | 分享 0
  • RSS EMail Me

Search

Latest logs

  • Share DOM Fixtures between JavaScript Unit Tests
  • Manage Mock Dependencies of Controllers with IoC Container
  • The Waste from Very Fat to Very Lean's Perspective
  • A Misleading Analogy between Software Development and Manufacturing
  • Selenium Test Powered by jQuery.parcel
  • Remove the Noisy Thread.Sleep and WaitForCondition from Selenium Tests
  • Code Snippet to Log All Events as They Are Triggered
  • A Quick Check of Javascript Code Quality
  • Implement Object Builder for Testing in a .NET Object Initializer Style
  • 看过《丰田现场管理方式》,30年前出版的书
全部日志>>

Comments

  • taowen:http://taowen.github.com/bay...
  • dewwind88:呵呵,我信!我也是自己深有同感~-网络上的陌生人,搜索到...
  • sean xu:项目忙完了吗?好像很久没写精益方面的文章了:)...
  • 菜头:good summary ^.^
  • luning:你是说如何确定适合自己team的switch频率吧,多尝...
  • jackie chen:LN,想问问:怎样计算switch pair rate ...
  • sabrina:路子分析的很有道理哦!...
  • sabrina:虽然我不是很懂技术,但是能看出你的用心,加油哦!...
  • ncholas ren:where is the 'continue...'
  • laura:不错,好好学习!

Categories

  • Lean[21]
  • Software Development[2]
  • Agile[15]
  • Life[1]
  • Economics[3]
  • Misc[0]
  • Test[7]
  • Javascript[3]

Tag

  • 敏捷[32]
  • 精益[29]
  • Agile[22]
  • 软件开发[19]
  • Lean[15]
More..