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


in reply to Suggestions for working with poor code

Very cool node.

With regard to the To Do list, I scatter them throughout my code if there is a place I need to do further work. However, I have a make rule for todo that searches for all of the lines with TODO in them and prints them out. So a usage of a TODO:

if ($whatever) { # TODO - Finish code to take over the world }

Becomes:

To Do List Dir/file.pl 132: Finish code to take over the world

When run through the following (ugly, suboptimal, but working) code in Tools/todo.sh:

#/bin/sh echo 'To Do List' find . -type f | xargs grep -n TODO | perl -ne '($file, $line, $rest) += split /:/, $_, 3; $file =~ s|^./||; $rest =~ s|.*?TODO.*?[-\s:]+||; + $rest =~ s|"[.;,]\s*$||; $rest =~ s|\\n||g; print "$file $line: \u$r +est\n"' | sort | uniq | grep -v '.#' | grep -v Makefile | grep -v CVS +/

Which I call from my Makefile:

todo: Tools/todo.sh

Kinda ugly, but it lets me put the TODO statements where I actually need to do the work. So I can proof out a block of code by writing narrative comments with TODO at the start of the line (behind comment characters of course). Then fill in the code later and not worry about missing a piece. Also since the TODOs are where the stuff needs to be filled in, I have lots of context around the issue and don't need to write as much as I would if they were at the top of the file. Plus anyone without something to do in the group can just type make todo and add some code. Finally, it is easier to add a TODO right where you need it, than bop up to the top of the file and then have to find where you were back in the code.

-ben