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

Re^14: quickness is not so obvious

by RonW (Parson)
on Jan 27, 2015 at 22:42 UTC ( [id://1114679]=note: print w/replies, xml ) Need Help??


in reply to Re^13: quickness is not so obvious
in thread quickness is not so obvious

Simple question, complex answer.

Summary: While they do highlight potential issues in code - like "hidden" side effects - some of the guidelines are just plain pedantic for the sake of being pedantic - like ++i vs i++. Some even force extra complexity, like not allowing break or continue (what Perl calls last and next) in loops. And some are just annoying.

While I agree the guidelines represent things we should be careful with, what really bugs me about the guidelines is not the guidelines themselves but that certain people take them as a license to assume we don't know what we are doing and so bludgeon us with the "rules". Yes, we are human and do make mistakes. But, as helpful as reasoned use of the guidelines can be, they don't prevent mistakes. Indeed, a program that is 100% compliant with the guidelines is almost always more complex, so is likely to "hide" more bugs then a reasonably written program where the programmer made no consideration of the guidelines.

Replies are listed 'Best First'.
Re^15: quickness is not so obvious
by BrowserUk (Patriarch) on Jan 27, 2015 at 22:53 UTC
    While I agree the guidelines represent things we should be careful with, what really bugs me about the guidelines is not the guidelines themselves but that certain people take them as a license to assume we don't know what we are doing and so bludgeon us with the "rules". Yes, we are human and do make mistakes. But, as helpful as reasoned use of the guidelines can be, they don't prevent mistakes. Indeed, a program that is 100% compliant with the guidelines is almost always more complex, so is likely to "hide" more bugs then a reasonably written program where the programmer made no consideration of the guidelines.

    I concur 100%.

    I think I'd be tempted to try and come up with an example of code that exaggerates the with/without guideline restrictions difference -- a bit like this versus this -- and try and get a discussion going about it.

    Of course, you'd have to to be very sure that the two were exactly equivalent in function; and preferably, as relevant to your day-to-day work as is practical.


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority". I'm with torvalds on this
    In the absence of evidence, opinion is indistinguishable from prejudice. Agile (and TDD) debunked

      How about something simple?

      use autodie; while (<>) { last if /^__END__/; next if /^\s*#/; ...; }

      Now, the same functionality implemented with the guidelines.

      (Since this is Perl, I am adapting the guidelines to encompass Perl concepts.)

      my $EndOfInput = 0; for my $file (@ARGV) { if (0 == $EndOfInput) { if (open(my $fh, '<', $file)) { while (my $line = <$fh>) { if (0 == $EndOfInput) { if ($line =~ /^__END__/) { $EndOfInput = 1; } else { if ($line !~ /^\s*#/) { ...; } } } } } else { die "Can't open $file: $!"; # we are allowed to die on fat +al errors } } }

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (7)
As of 2024-04-19 12:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found