Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^2: inheritance: constructors

by Anonymous Monk
on Dec 01, 2012 at 02:50 UTC ( #1006562=note: print w/ replies, xml ) Need Help??


in reply to Re: inheritance: constructors
in thread inheritance: constructors

Please, I beg you, do not tell people they should use an else/unless construct. Ever. I wish this wasn't even possible. People need to think in the proper order.


Comment on Re^2: inheritance: constructors
Re^3: inheritance: constructors
by Anonymous Monk on Dec 01, 2012 at 02:52 UTC
    See? I can't even think "unless/else" properly. Ugh. Backwards thinking is why so many of us Perlmongers get made fun of by the other programmers. And why our successors curse our names when they have to maintain our code. Stop the madness.
Re^3: inheritance: constructors
by Athanasius (Monsignor) on Dec 01, 2012 at 03:33 UTC

      Sorry, I'm not buying. This is not ok? --

      if ( $value != $expected_value ) { $errorcount++; die new Exception msg => "argh!"; } else { # continue with the happy path }

      But this is ok? --

      if ( $value != $expected_value ) { $errorcount++; die new Exception msg => "argh!"; } # continue with the happy path

      no, no, no.

      I reckon we are the only monastery ever to have a dungeon stuffed with 16,000 zombies.

        Well, in

        if (...) { die ...; } else { # continue with the happy path }

        the provision of an else block is redundant, since it suggests (misleadingly) that the code can somehow die and yet still resume execution following the else — which it can’t.

        For this case, I would prefer:

        unless ($value == $expected_value) { $errorcount++; die new Exception msg => "argh!"; } # continue with the happy path

        which reads more naturally (to my ear). (Note that the original objection was not to unless, but to unless ... else.)

        Update: Nice use of the <abbr> tag, BTW — I’ve learnt something new, could come in handy.  :-)

        Athanasius <°(((><contra mundum

      You assume the order of the code blocks does not matter, too most ppl it does.

      Either: if ($i != $j) or: unless($i == $j)

      Chose one, these are the same. Your example changes much more than just removing a double negative.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (8)
As of 2014-08-23 15:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (174 votes), past polls