• 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.