On May 21, 11:11 pm, "T.J. Crowder" <t...@crowdersoftware.com> wrote:
> Hi Joe,
> > T.J.'s factory suggestion...
> FWIW, I think it was Doug's suggestion, I just updated it a bit.
> > function DateFactory(){
> >   var fName, that = new Date();
> >   for (fName in SpecialDateProps)
> >     that[fName] = SpecialDateProps[fName](); // Note calling the
> > fName's function.
> >   return that;
> > }
> I'm not immediately seeing how that works.  There are two problems I
> see:
> 1. When you're calling the functions, they don't have any context to
> work with.  How do they know what date they're meant to be working on?

Which means creating setters and getters so that when the date is
modified, properties can be adjusted accordingly.  However, that means
setters may be doing more work than they need to - why work out if a
date is easter or not if the code using it date doesn't care?

> 2. Date instances are mutable, but you're setting a flag on the date
> just once at creation time.  So even if the flag is correct at the
> time the instance is created, it can be made incorrect by using any of
> the mutator functions (setMonth, etc.).

Either the setter needs to update such propeties, or isEaster needs to
be a method, not a boolean.  It all boils down to understanding the
requirements first, then designing the software to suit.

You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
For more options, visit this group at 

Reply via email to