On 7/3/07, Mislav Marohnić <[EMAIL PROTECTED]> wrote:
> On 7/3/07, justin blecher <[EMAIL PROTECTED]> wrote:
>
> > my goal is to have some class variables that are used for configuration of
> > the class
>
> You're not doing unconventional stuff, just overcomplicating. Look at how
> options vs. default options are handled in the Ajax module or
> Script.aculo.us

mislav, thanks for your quick reply.

i do concede that my example syntax is more wordy than one would
desire, but the end result is that the config options are extracted
from the methods themselves -- something i feel is worth the
compromise. it allows the setting of options in the initialize method
to be reduced to just one line, (making the initialize method easier
to follow):

  this.setOptions(options);

... assuming i have a BaseWidget.prototype.setOptions method along the lines of:

  setOptions : function(options) {
    this.options =
Object.extend(Object.clone(this.constructor.DEFAULTS), options || {});
  }

i realize it's just personal preference from here on out, and i
certainly don't want to start any holy wars. :)  i'm just trying to
get a basic pattern down so i can brief my peers on The Right Way to
build JS widgets using Prototype.

can the community look forward to any 'official' best practices guide
from the core team? i have a bunch of widgets that i'd like to
publish, but want to make sure they all have a consistent (and sane)
interface before i let them loose on the intarwebs.


cheers,

-justin

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to