Slash Boxes
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.
More | Login | Reply
Loading... please wait.
  • # Hello Demeter!  (Yeah, this is contrived)
    my $office = $cust->salesman->manager->office;
    What's wrong with this?
    • my $office = $cust->salesman->manager->office;

      It's a question of encapsulation. Imagine that the Salesman class no longer has need of a manager accessor, but you still need to know which office the salesman is with. You might get a office method pushed into the Salesman class. Then, every place where you have the above code needs to be changed to:

      my $office = $cust->salesman->office;

      If that's called a lot, it can be a maintenance nightmare.

      However, what if you have this?

      sub Cus