I'll vote for this one too. In our development team, for all class design this is our standard. Return the existing value if one isn't supplied as an argument. Set the value and return self if there is a supplied argument.
It works so well that we designed a base class that does all of the getting and setting of attributes an all our methods need to be in the class we are designing is: sub day { $self->_get_set( _day => @_ ) } It allows rapid development of new classes. Well that's my 2 cents, Michelle Agnew Lead Operations Software Developer The Internet Marketing Center > If we do change the naming, I vote for > > $dt->day; > $dt->day(1); > > But I'm not too annoyed about this particular naming thing... > > --d > > David Wheeler wrote: > > On Jul 15, 2004, at 2:40 PM, Dave Rolsky wrote: > > > >> $d->day(1) and friends should be the equivalent of $d->set(day => 1) > >> to make the interface consistent and obvious. > > > > > > Hrm. I'm inclined to agree, I think. I like having separate accessors > > and mutators but DateTime's current model: > > > > $d->day; # accessor > > $d->set_day(1); # mutator > > > > Has a different naming convention for the two types of methods. I kind > > of like it, but only in environments where attributes are virtually > > always READ, and rarely WRITTEN. So maybe it should be: > > > > # Perl-style > > $d->day; # accessor > > $d->day(1); # mutator > > > > Or: > > > > # Java-style > > $d->get_day; # accessor > > $d->set_day(1); # mutator > > > > Thoughts? > > > > David > > > >