in reply to Re^2: Method Chaining and Accessors
in thread Method Chaining and Accessors
Myself, I'm inclined to name my setters "set_*" but to avoid using the prefix "get_" on my getters
But then your getters look exactly like the mutators you're trying to avoid! infact, your getters have exactly the same surprise toy inside!
my $foo = Foo::Doom->new(); $foo->bar( 'shoe' ); # OH NOES! its just a getter # but it still looks right -_- # whereas my $f00 = Foo::f00li5h->new( in_accordance_with => TheDamian ); $f00->get_bar( 'shoe' ); # what the hell is 'shoe' there for? # this is clearly a getter
Sure if you've got a bundle of other setters called, as set_foo in exactly the same place that you're adding the new code to set bar, you're a little less likely to write $foo->bar('shoe'), but only a litte.
Personaly, I'd expect $foo->bar to be a mutator.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Method Chaining and Accessors
by doom (Deacon) on Apr 11, 2007 at 19:44 UTC | |
by f00li5h (Chaplain) on Apr 12, 2007 at 02:28 UTC | |
by doom (Deacon) on Apr 12, 2007 at 16:14 UTC | |
by f00li5h (Chaplain) on Apr 12, 2007 at 17:07 UTC | |
by doom (Deacon) on Apr 13, 2007 at 19:23 UTC | |
|