[jQuery] About plugin best practices

[jQuery] About plugin best practices


Hi,
I'm still a newbie and now writing my own plugin, i'd like to ask 2
questions, taking as best pratice :
http://jquery.bassistance.de/jquery-getting-started.html
# Optional: Create an object with helper functions, eg.:
jQuery.fooBar = {
height: 5,
calculateBar = function() { ... },
checkDependencies = function() { ... }
};
# Optional: Create default settings that can be changed by the user, eg.:
jQuery.fn.foobar = function(options) {
var settings = {
value: 5,
name: "pete",
bar: 655
};
if(options) {
jQuery.extend(settings, options);
}
};
1. I didn't get the value/interest of "creating an object with helper
functions, and then call these helper function from within your plugin"
Memory/performance reason? just design pattern?
2. What should i do if i want the height property of fooBar object to be
user-defined when calling the plugin = height as a plugin setting?
This way below seems not good to me since i'll have 10 parameters to pass:
jQuery.fooBar = {
height: 5,
calculateBar = function() { ... },
checkDependencies = function(*height*) { ... }
};
jQuery.fn.foobar = function(options) {
var settings = {
value: 5,
name: "pete",
bar: 655,
*height: 200*
};
if(options) {
jQuery.extend(settings, options);
}
// do something
*jQuery.foobar.checkDependencies(settings.height);*
// do something else
};
Thanks
Phil