On 9/8/06, Sam <[EMAIL PROTECTED]> wrote:
> When a point is completely missed in the documentation, it's usually because 
> it's obvious to the writer and almost all the readers.
> I'll dive in and ask the obvious.
>
> The plugin skeleton shown below is taken from the plugin model overview at :
>
> http://jquery.com/plugins/Authoring/
>
>    new function() {
>       var privatedata = 42;
>
>       $.fn.mypluginmethod = function() {};
>
>       $.myplugin = {
>          publicmethod1: function() {},
>          publicmethod2: function() {}
>       };
>
>       function privatehelper() {}
>    }();
>
> 1 - I see jQuery coders like to encapsulate code in autonomous functions, but 
> I haven't read anything about why, and I'm not clear
> on why.  The benefit would be that locally declared variables aren't 
> externally visible?  That is, wouldn't the following code
> perform as well?
>
>       var privatedata = 42;
>
>       $.fn.mypluginmethod = function() {};
>
>       $.myplugin = {
>          publicmethod1: function() {},
>          publicmethod2: function() {}
>       };
>
I think if you don't encapuslate the privatedata in a function, even
if it's was declared with var, but because it's defined in top level
scope, so it'll still be a global variable. And this will not what I
think.

> 2 - The documentation describes the $.myplugin.publicmethod1 as being a 
> technique for coding "private" functions.  So wouldn't it be
> more intuitive to write:
>
>       $.myplugin = {
>          privateMethod1: function() {},
>          privateMethod2: function() {}
>       };
>
> And on a related note, if we like documentation with public/private in the 
> names to improve the clarity, why isn't
> $.fn.mypluginmethod (in 1 above) named $.fn.myPublicMethod?
>
> Good questions or complete idiot?  Only the responses will tell.  ;-)
>
> Sam
>
Maybe the function name is too long.

-- 
I like python!
My Blog: http://www.donews.net/limodou
UliPad Site: http://wiki.woodpecker.org.cn/moin/UliPad
UliPad Maillist: http://groups.google.com/group/ulipad

_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to