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.8.8.32.11.32"

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