Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Re: multiple method calls against the same object (f.ex GUI programming)

by dada (Chaplain)
on Oct 28, 2002 at 15:25 UTC ( #208522=note: print w/ replies, xml ) Need Help??


in reply to •Re: multiple method calls against the same object (f.ex GUI programming)
in thread multiple method calls against the same object (f.ex GUI programming)

...but this requires that each of these configurator calls returns $self as the last step, which is frequently the case...

just out of curiosity, but with this design in mind how would you return a value from a method call? even a simple boolean for success/failure. for example, how could you do something like:

$window->set_title("Test") or die "Can't set title!\n";
if you're always only returning $self?

cheers,
Aldo

King of Laziness, Wizard of Impatience, Lord of Hubris


Comment on Re: Re: multiple method calls against the same object (f.ex GUI programming)
Download Code
•Re: Re: Re: multiple method calls against the same object (f.ex GUI programming)
by merlyn (Sage) on Oct 28, 2002 at 15:27 UTC
    Just use exceptions instead. Nothing wrong with wrapping a series of these things in an eval block to catch the exception.

    I prefer exceptions when an action will likely work 95% of the time or more. That way, the testing doesn't interfere with my examination of the control flow, and you get to do nice tricks like a "return $self" chain.

    -- Randal L. Schwartz, Perl hacker
    Be sure to read my standard disclaimer if this is a reply.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (8)
As of 2014-08-22 06:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (148 votes), past polls