Often, we discover an edge case, or know we want to improve some aspect of our code, but don’t have the time or energy to get to it right now. Hopefully we document these notes somewhere, but even if we do document them, there are some problems.
If we use an external task manager, these tasks could get out of sync with the actual codebase. And unless you leave a file and line number, you might not remember where exactly the issue is.
You might leave comments in your code, but those will inevitably be forgotten and ignored.
Rails comes with a hidden feature to help with managing your list of to-dos. As you’re writing code, you can leave one of these three notes:
"#TODO: handle edge case where x happens"
"#FIXME: this breaks under x condition"
"#OPTIMIZE: this takes 5 database queries"
And then, running rake notes (or rn if you’re making use of the aliases in the Aliases for Common Rails Commands section) will enumerate every note you’ve left in your code:
While you still have to take the initiative to go back and refactor your code, this will at least give a quick overview of what’s left to be done in your application and where to find it.
Don’t like the default TODO, FIXME and OPTIMIZE? You can also enumerate custom annotations:
rake notes:custom ANNOTATION=NOTE