http://www.perlmonks.org?node_id=1172741


in reply to Don't post bad code!

Hi Alexander,

I agree with many things in your meditation. I do want to provide some counterpoints to a few things.

But no, we should not show beginners the most dirty ways first.

I absolutely agree, if the emphasis is on "first". But I think it's a little unfair to pick on 1172628: it was posted several days after two very good replies showing the better way to accomplish the OP's goal, it does contain a disclaimer, and I'm pretty sure it'll stay near the bottom of the page. The only thing I felt missing in that node is a discussion of strict, which I have now added in a reply.

... Not even with warnings not to use the dirty ways in production code.

I disagree: If a question is first answered with the "best practice" way, then I think that posting the one-liner or "bad" way afterwards - with a prominent disclaimer - isn't a bad thing. People who are just looking for a quick answer to copy-and-paste into their script (of whom there are many) will use the first thing they find, which will usually be the first and/or most-upvoted answers, especially since the relatively recent change that replies are sorted "best first" by default. But threads are read by many more people, and those who actually want to learn Perl (hopefully including the OP) can scroll down, and they will learn something interesting.

People will always find bad code all over the 'net and use it. Just the other day I came across a blog posting showing an arguably bad snippet of Perl code, and the only indication that there was something wrong with it was if you scrolled down into the comments section (which had a tiny font). So instead, I think that showing both the right way(s) and the "wrong" way with a prominent disclaimer will help people to differentiate between the two, and to learn why something is "bad".

Note that I'm putting "bad" and "wrong" in quotes here because I'm a fan of TIMTOWTDI, while at the same time I think that guiding people to using the best practices is also a Good Thing.

There lots of threads where I see replies and think "I wouldn't have posted that", such as the many cases where people get code written for them where I happen to feel they haven't shown enough of their own efforts. But getting frustrated that I can't control what other people post is not the answer :-)

Instead I like the system that is already in place: Replying to nodes that contain "bad" code, and the voting system. Monks who truly want to contribute will quickly learn that posting replies that adhere to best practices is appreciated by more people. Your meditation is also good reminder of the "best practices of posting".

Regards,
-- Hauke D

Replies are listed 'Best First'.
Re^2: Don't post bad code!
by afoken (Canon) on Sep 28, 2016 at 05:44 UTC
    I think it's a little unfair to pick on 1172628: it was posted several days after two very good replies showing the better way to accomplish the OP's goal, it does contain a disclaimer,

    Yes, maybe. It is not the best example for a "bad code" posting, and I know that there are worse postings. But as I wrote: It is the posting that triggered my meditation. It was the straw that broke the camel's back.

    There lots of threads where I see replies and think "I wouldn't have posted that", such as the many cases where people get code written for them where I happen to feel they haven't shown enough of their own efforts. But getting frustrated that I can't control what other people post is not the answer :-)

    (I'm not frustrated.)

    Instead I like the system that is already in place: Replying to nodes that contain "bad" code, and the voting system. Monks who truly want to contribute will quickly learn that posting replies that adhere to best practices is appreciated by more people.

    Very good point. It does not require any changes to the monastery code, and everyone can contribute. Simply by posting "Don't do that. It's the path to the dark side. 'Once you start down the dark path, forever will it dominate your destiny.' -- Yoda" Yoda quote optional. ;-)

    Alexander

    --
    Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)