http://qs321.pair.com?node_id=259928


in reply to Short Refactoring Tip: let the object do it for you

You are on the right road, but it seems as if nobody has mentioned your solution is not good OO design:

BAD:           if ($po->status->name eq 'Sent') ...
ALMOST AS BAD: if ($po->can_send) ...
GOOD:          $po->send

You are breaking encapsulation in all but the last case. Getters are a design smell. They are just a way to make private data public.

Instead of asking objects questions, tell them to do things. The object will figure out how to do it.

Allen Holub says about this:

"Never ask an object for the information you need to do 
something; rather, ask the object that has the information 
to do the work for you."