Re: markAsClean

Kris Leite <[email protected]> Sun, 04 May 2008 21:09:03 -0700
Newsgroups gmane.comp.java.helma.general
Message-ID <[email protected]>
Using getter/setters for this is possible.  I find the simple assignment 
statement in onInit to be much less code, execute overhead, and 
debugging needed.  The markAsClean function can be useful in other 
situations besides this one.


Joshua Paine wrote:
> On Sun, 2008-05-04 at 18:49 -0700, Kris Leite wrote:
>   
>> In my case, it was much better to 
>> create HopObject fields with default values.  If the user changed the 
>> default values, then they are stored.  If nothing was entered, then
>> the default values are not stored reducing storage overhead.
>>     
>
> This would probably be even better accomplished like this:
>
> this.__defineGetter('favColor',function(){
>   return this.favColor_ === undefined ? 'red' : this.favColor_;
> });
> this.__defineSetter('favColor',function(val){
>   val == 'red' ? (delete this.favColor_) : this.favColor_ = val;
>   return val;
> });
>
>