Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re: How not to write subroutines

by strat (Canon)
on Jan 15, 2006 at 10:38 UTC ( #523320=note: print w/replies, xml ) Need Help??

in reply to How not to write subroutines

At university, a professor once told us also to comment when, why and in what mood we wrote some code, e.g

# 11.11.2004, late night # replaced global filehandles with lexical ones # after having drunk eight beers

I wrote some amazing code when I was drunk,
and debugged some terrible code when I was sober

Best regards,
perl -e "s>>*F>e=>y)\*martinF)stronat)=>print,print v8."

Replies are listed 'Best First'.
Re^2: How not to write subroutines
by nacka (Friar) on Jan 15, 2006 at 13:38 UTC
    I kind of liked the idea of putting in the mood of the programmer in comments.
    # code to mimic uniq(1)
    # mode: divine my @result = do { my %counter; grep ++$counter{$_} == 2, @input; };
    # mode: tired for (@input) { $multiples{$_}++; } for keys( %multiples ) { print "$_\n" if (--$multiples{$_}); }
    (And yes, both example stolen from Get All Duplicated Elements in an Array (Once, without shifting), and I mean absolutly nothing with the different modes.)
    And when refactoring this code, a mode that suggest that the programmer was tired, drunk or thought him-/herself being merlyn is prime candidates for a rewrite.

      That's actually a good idea. I think I might just start doing that.

      "If you go on with this nuclear arms race, all you are going to do is make the rubble bounce" -- Winston Churchill

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (5)
As of 2019-06-18 06:36 GMT
Find Nodes?
    Voting Booth?
    Is there a future for codeless software?

    Results (81 votes). Check out past polls.

    • (Sep 10, 2018 at 22:53 UTC) Welcome new users!