Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

Id like to point out that this doesn't scale very well. Sure you have a valid point in a limited case, such as when there are only a few relevent states. But what happens when there are lots? Or the system is dynamic? Or if you want to say things like

if ($po->status->name =~ /^(sent|pending|waiting|procratinating|delaye +d)$/i) {

I'd rather write the above than call a bunch of methods, let alone write the methods in the first place. :-)

I thinks its unlikely I would write an object that require on a regular basis the double indirection like that. And if I did face a situation like my example above I'd probably do something more like

my $status=$pos->status; if ($status->is('Pending')) {} if ($status->in(qw(sent pending waitning procrastinating delayed)) { }

The issue here for me is that the use of 'Pending' isn't wrong, its the use of 'Pending' in such a way that I can't intercept that usage that is wrong. The subs above allow use to redefine the back end behaviour just as yours does, but its a lot more flexible an approach, while still providing us a way to block inapropriate checks. For instance $status->is('Pneding') should produce an error. Albeit a run time one. Oh well you cant have everything can you? :-)

Anyway, I use both styles as seems appropriate for the task at hand, often both at the same time even. :-)


<Elian> And I do take a kind of perverse pleasure in having an OO assembly language...

In reply to Re: Short Refactoring Tip: let the object do it for you by demerphq
in thread Short Refactoring Tip: let the object do it for you by Ovid

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (2)
As of 2022-10-07 19:04 GMT
Find Nodes?
    Voting Booth?
    My preferred way to holiday/vacation is:

    Results (30 votes). Check out past polls.