Stories
Slash Boxes
Comments
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

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • Method chaining is fine as long as it's clearly documented and consistent within a module. I would be hauled off to the looney bin if I were to make any kind of global recommendation, however.

    In my new Alpaca book [oreilly.com], I argue that for a getter/setter method, there are arguments in favor of any one of four return values from the setter method:

    • a simple true/false status (yes I was able to set this),
    • the newly set value, turning the setter into an immediate getter as well,
    • the previous value (ala umask and single-arg select), allowing flip-flop settings trivially, or
    • the object itself, allowing for chained settings.
    For anything but the first, a die has to be used to signal error.

    As long as it's documented, it's fine. Don't demand consistency. Any one of these four returns is fine.

    --
    • Randal L. Schwartz
    • Stonehenge