Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Golf: Improve this guy's fail . . . please!

by ELISHEVA (Prior)
on Jul 01, 2009 at 07:22 UTC ( #776334=note: print w/ replies, xml ) Need Help??


in reply to Golf: Improve this guy's fail . . . please!

I realize this was posted with good intent as a learning experience/game for us here at Perl monks, but I have very mixed feelings about this post.

On one hand, I view coding as a responsibility. The number of people who know how to use code far outnumber the number of people who know how to write even bad code. The number of people who know how to write code (bad or good) far outnumber the the number of people who know how to scan code for errors or security risks. Those of us who know how to code have a responsibility to either (a) post in a forum where we can be easily critiqued or (b) post code that has been throughly tested. From that perspective, if you post bad or careless code on an isolated blog, you deserve what you get.

On the other hand, a rule of thumb I use when I criticize anyone in terms that are even remotely identifiable is "Can I say it to their face?". If I can't do that, I feel I don't have the right. When I saw this post, my first thought was to email the person and say here is some feedback you can learn from, but then I couldn't think of a way to say it that wouldn't run the risk of embarrassing him. So, for me, at least,it failed the 'can I say it to his face' rule. Maybe not though for others - I may just lack the creative tact needed. The only other option, keeping the author totally anonymous, would have been wrong. No matter how bad the code is, there are copyright and plagiarism issues with extensive unattributed quotes.

I just felt I needed to share that.

Best, beth


Comment on Re: Golf: Improve this guy's fail . . . please!
Re^2: Golf: Improve this guy's fail . . . please!
by mr_mischief (Monsignor) on Jul 01, 2009 at 18:44 UTC
    I looked for a place to reply to the code's original author on his page, and found none. I found an email address and a Google Talk account name tied to it. I tried to message him via Google Talk, but although he advertises it in his contact info he requires potential "buddies" to be approved. I followed links from his Blogger account to another web site he has, but the contact form there is disabled. I'm not going to go to the trouble of opening a fourth interface to contact him, but his email address is available in his Blogger contact info if you'd rather avoid the first three I tried. At some point, it's an author's responsibility to make contacting him waste less of a commenter's time if the author really wants to be contacted.
Re^2: Golf: Improve this guy's fail . . . please!
by dragonchild (Archbishop) on Jul 02, 2009 at 18:59 UTC
    You don't know me very well. :)

    I have, on many occasions, told someone he was being an idiot. I'd love to tell the poster the same thing, but I'm not going to hunt him down. It's not worth my time.


    My criteria for good software:
    1. Does it work?
    2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?
      Hi, I'm the poor schmuck you've been referring to. I've been trying to teach myself Perl in between classes for a couple months now (my college only really offers Java). I know my code is inelegant, but I'm also still really new to Perl. The program being laughed at was my attempt to help a friend from another class--he needed a character counter and he needed it fast, so I tried to hack one together in Perl for him (in case anyone is going to mention cheating, he wasn't turning my code in for an assignment). I'm sorry, I honestly didn't know that my code was so bad. I agree with the above post about responsibility, though I thought I was doing right by making all of my source open and available. The hope was that someone might find a post or two useful if they were trying to learn Perl too. When I found this thread on PerlMonks I laughed a little. You see, about two days ago I noticed that my blog was actually getting traffic and that a lot of it was from PM. I joked with my wife that it was really cool that I was getting referrals from a site like PM...unless I was the "How Not to Code" showcase of the week. Anyway, I didn't realize that my blog was doing harm--I'm going to take it down after I finish this post. Maybe after I've been studying Perl for a few years I'll hazard writing some tutorials for CIS students, but I'll try to go through proper channels to do so. To the couple of you that tried to contact me, email is usually the easiest way: zhespelt at gmail dot com.
        I know it's not as elegant as the code above, but I think it's a bit better than my first one.
        #!/usr/bin/perl -w use strict; use warnings; local $/ = undef; my $string = <>; my @array = split(//, $string); my %hash; foreach (@array) { if ($_ =~ /\w/) { $hash{$_}++; } } my @keys = sort keys %hash; my $total; foreach (values %hash) { $total += $_; } foreach (@keys) { printf "%s\t%d\t%.3f\n", $_, $hash{$_}, $hash{$_}/$total; } print "$total characters\n";

        Welcome to the monastery by the way! I hope you'll stay. It's well worth hanging around here.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (6)
As of 2014-09-15 10:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (146 votes), past polls