GTD on Rails with Annotations

You are in the zone.

Beautiful code is flowing from your fingertips and forming on screen, resolving into a true work of art.

Your tests cover just the right amount of your code, and the few tests that don’t pass are failures rather than errors; regardless they are corrected within seconds.

The design has taken on a life of it’s own, and it is spreading tendrils like wisps of smoke outwards in all directions.

It’s clear that this project will be ready for it’s first release ahead of schedule, when it happens.

Your thoughts diverge in multiple directions.  You cannot decide which task to persue.  You choose to complete the code that will make your current failing test pass.  But, those other things were pretty important too.  You freeze.  Concentration is lost.  It all falls apart.

Recently I found some rails rake tasks that will help in this situation or anywhere else that you want to place a marker to come back to later; perfect for code reviews as well.

rake notes                                # Enumerate all annotations                                                                                       
rake notes:custom                         # Enumerate a custom annotation, specify with ANNOTATION=WTFHAX                                                   
rake notes:fixme                          # Enumerate all FIXME annotations                                                                                 
rake notes:optimize                       # Enumerate all OPTIMIZE annotations                                                                              
rake notes:todo                           # Enumerate all TODO annotations

simply mark the code you are intersted in remembering such as the following

class ExampleController
  def new
    @design = Design.new
    #TODO wookie
  end

  def create
    #OPTIMIZE this needs help
    #FALAFEL yummy in sandwiches.
    @design = Design.new(params[:design])
    @design.profile = Identity.find(current_identity).profile

    #FIXME This was supposed to support xml!
    if @design.save
      flash[:message] = "Design added."
      redirect_to design_url(@design)
    else
      flash[:error] = "Error saving Design."
      render :action => :new
    end
  end
end

when you run rake notes you get

rubyyot@atlas:$ rake notes
(in /home/rubyyot/working/example)
app/controllers/example_controller.rb:
  * [ 10] [TODO] wookie
  * [ 14] [OPTIMIZE] this needs help
  * [ 19] [FIXME] This was supposed to support xml!

Notice you get the exact location of the note along with the type and the text of the note.

Alternatively you could use custom tags with this like this.

rubyyot@atlas:$ rake notes:custom ANNOTATION=FALAFEL
(in /home/rubyyot/working/example)
app/controllers/example_controller.rb:
  * [ 15] yummy in sandwiches.

Tags: , , , ,

2 Responses to “GTD on Rails with Annotations”

  1. [...] learn to find the TODO annotation again with rake. Share this entry Hide Sites [...]

  2. [...] When inspiration strikes, annotate! – Rather than getting sidetracked by things outside of the scope of the current feature, leave a note and come back to it. [...]

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">