[Cosmo-dev] CosmoUI Data Model Proposal
Matthew Eernisse
mde at osafoundation.org
Tue Mar 27 13:49:57 PST 2007
Responses below.
Bobby Rullo wrote:
> I may be using the terminology incorrectly (I wanted to say "class"
> originally but I knew that was wrong for sure!) but I don't understand
> your explanation - could you point me to the crockford article?
Yeah, there doesn't seem to be any real consensus on what to call it,
since it's not actually a class, but it's still used as a template for
other objects.
Crockford refers to them as 'pseudo-classes' in his "Advanced
JavaScript" lecture up on YUI Theater:
http://yuiblog.com/blog/2006/11/27/video-crockford-advjs/
He calls the pattern of using constructor functions (e.g, 'new
Thinger()') to create objects 'Pseudoclassical Inheritance,' because it
tries to make JS's prototype-based inheritance look like Java.
> I was thinking more like:
>
> Item.prototype.addStamp = function(stamp){
> this.stamps[stamp.namespace] = stamp;
> }
Should that be:
this.stamps[stamp.stampMetaData.namespace] = new stamp();
The namespace looks like it's down in the metadata -- and you need an
instance of the empty stamp, right?
It looks like the only stuff that's actually hardcoded is the name of
the pseudo-class (e.g., 'EventStamp'), and all the attributes in
StampAttribute. Is the idea to have some code that runs on init that
creates the constructor functions for all the various stamp types
programmatically?
> Why not have both? I'm not talking about convenience methods for every
> type of stamp, just stamps that are part of core functionality. Wouldn't
> you rather type:
>
> item.getEventStamp();
>
> than
>
> item.getStamp(SOME_CONSTANT)
>
> ?
Less typing = good. :)
>> I'm guessing that since that's mostly view-specific, we'll be
>> maintaining sorted/filtered lists (Hash, some sort of collection,
>> whatever) in the various views that point to the Items that are also
>> in some central list. Is that what you're thinking?
>>
>
> Yes to the first bit, but I wasn't really thinking of any central list,
> if you mean by that a single place where "known" items are stored.
If there's no central list of items, where do you put the things you
load from the server? Or rather, if there are multiple views all
consuming the same data, where does that data live?
Matthew
More information about the cosmo-dev
mailing list