Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Re: object aggregators

by demerphq (Chancellor)
on Jun 15, 2003 at 09:07 UTC ( [id://266011]=note: print w/replies, xml ) Need Help??


in reply to Re: object aggregators
in thread chaining method calls

However, method chaining is completely counterintuitive, because it's not natural to have $object->make_head('larger') return the object with the head made larger. One would expect it, like most methods, to return true on success and false on failure.

Well, it does return true on success. And when you provide for method chaining you usually use exception handling and not inband error codes. As for indenting the chain, thats a matter of taste. All I know is that I sure am glad I can type:

print Data::Dumper->new([$foo],[qw(foo)])->Indent(2)->Purity(2)->Dump( +);

Instead of

print do{my $d=Data::Dumper->new([$foo],[qw(foo)]); $d->Indent(2); $d- +>Purity(2); $d->Dump()};

And any hard and fast rule that says I can't/shouldn't do the above I would reject as being utterly unworkable in practice.

As I said elsewhere in this thread, the probable and common usage case should be the deciding factor in how a given method behaves. One shouldn't have to contort oneself to fit into some arbitrary coding scheme when there is no reason to. The Perl motto for things like this is that easy things should be easy and hard things possible. Selecting a method design that meets these requirements is the only design criteria as far as I am concerned.
---
demerphq

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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://266011]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2024-03-28 23:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found