Snip
|
Global variables are evil. Within YUI, we use only two g... YAHOO_config. Everthing in YUI makes use of members with... object hierarchy or variables that are scoped to such a ... that you exercise similar discipline in your own applica...
|
---|
Categories |
|
---|
For Snip |
loading snip actions ... |
---|---|
For Page |
loading url actions ... |
Global variables are evil. Within YUI, we use only two globals: YAHOO
and YAHOO_config
. Everthing in YUI makes use of members within the YAHOO
object hierarchy or variables that are scoped to such a member. We advise that you exercise similar discipline in your own applications, too.
Douglas Crockford has been teaching a useful singleton pattern for achieving this discipline, and I thought his pattern might be of interest to those of you building on top of YUI. Douglas calls this the “module pattern.” Here’s how it works:
HTML |
<p><a href="http://yuiblog.com/blog/2006/06/01/global-domination/">Global variables are evil</a>. Within <a href="http://developer.yahoo.com/yui/">YUI</a>, we use only two globals: <code>YAHOO</code> and <code>YAHOO_config</code>. Everthing in YUI makes use of members within the <code>YAHOO</code> object hierarchy or variables that are scoped to such a member. We advise that you exercise similar discipline in your own applications, too.</p> <p>Douglas Crockford has been teaching a useful singleton pattern for achieving this discipline, and I thought his pattern might be of interest to those of you building on top of YUI. Douglas calls this the “module pattern.” Here’s how it works:</p> <p></p> |
---|