Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
I am not only in the 'love it' camp, i am also responsible for helping spread this:
# stackable method calls: print DBIx::XHTML_Table ->new($data_source,$usr,$pass) ->exec_query('select foo,baz from bar') ->output() ;
The first time i saw this (and it was in SOAP::Lite as well, BTW) i was a bit perplexed, but once i understood the convience it gave to the client, i loved it. Could it make debugging harder for the client? Sure! Answer? Don't use it!
my $table = DBIx::XHTML_Table->new($data_source,$usr,$pass); $table->exec_query('select foo,baz from bar'); print $table->output();
I went back over my CVS tree to see when i added the change, and what comments i added:
Version 0.98 (12/31/2001)
- all methods that normally returned void now
  return $self (this allows stacking methods)
However, i must admit that the large number of folks who don't like this does impact me a bit. I will keep an eye out for bugs that 'stackable methods' might introduce, but i have honestly had no troubles with them, be it debugging or what not. The key is to use the 'plain old boring' style while testing.

Finally, this 'stackable method' style is most likely only for certain OO candidates. DBIx::XHTML_Table (while feature loaded) is a very simple module. All methods serve to get the final output, and i think that is what makes chaining them okay for that module. Other modules might be better off sticking to individual calls.

Damn good question again, perrin :)


(the triplet paradiddle with high-hat)

In reply to (jeffa) Re: chaining method calls by jeffa
in thread chaining method calls by perrin

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

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others browsing the Monastery: (7)
    As of 2018-05-24 14:52 GMT
    Find Nodes?
      Voting Booth?