NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.
All the Perl that's Practical to Extract and Report
Stories, comments, journals, and other submissions on use Perl; are Copyright 1998-2006, their respective owners.
accessors (Score:1)
This is the reason I am leaning more and more towards Class::Accessor and similiar. I note that you'd have to override set() to return $self that way, however.
-Dom
Re:accessors (Score:1)
> that before. This is a more general code issue,
> and it's probably fine for your small code, but
> what happens if you want to store undef in your
> accessor?
Generally I work very hard to make sure I never need to have an undef in any given state
The object in question will always be in one of two states:
- Usable - there is a valid LWP::UserAgent object
- Unusable - there is no valid LWP::UserAgent object
Cases can be made for wanting to store undef howeverI'm pretty big on returning $self from accessors in 'set' mode. That way you can move parameter passing away from the constructor, which makes subclassing later on much easier. If you want set things up at construction time, you can chain your method calls, and still get everything nice and concise in the real estate department without sacrificing flexibility.
Or maybe I'm a SmallTalk junkie
Reply to This
Parent