revUp - Updates and news for the LiveCode community
Issue 128 | February 10th 2012 Contact the Editor | How to Contribute

The Pomodoro Technique
Create this neat little timer app in LiveCode to promote your productivity

by Andre Garzia

The Pomodoro Technique is a time management technique that is getting very popular among the development crowd. This technique was invented by Francesco Cirillo in the eighties and is very simple. You work in intervals called pomodoros. Each interval is 25 minutes long. After each work period, you take a rest period of 5 minutes. Every four pomodoros, you take a longer break, between 10 and 20 minutes. Francesco used a kitchen timer in the shape of a tomato, he would wind up this pomodoro timer for a 25 minutes work interval and then after completing the pomodoro, he would set it to a 5 minutes break. The workflow is like this:

  • Decide on a task to do.
  • Estimate how many pomodoros it would take to complete it.
  • Wind-up your pomodoro timer for a 25 minutes work interval.
  • After working for 25 minutes, rest for 5 minutes.
  • Every four pomodoros, rest between 10 to 20 minutes.
  • When the task is completed, compare how many pomodoros were needed to your original guesstimate. This will help you gauge your productivity.

There is more to the Pomodoro Technique than just this and everyone is welcome to read about it at http://www.pomodorotechnique.com/. Francesco Cirillo wrote a great book that is freely available from this website. For the graphically oriented among us, Pragmatic Bookshelf has an illustrated guide on the Pomodoro Technique available at http://pragprog.com/book/snfocus/pomodoro-technique-illustrated.

As I said, this technique is getting very popular on the internet and has spawned hundreds of small pomodoro timer applications for all the different systems out there. There are timers for iOS, Android, Mac, Linux, Windows... Here in this article we’ll build our own.

Building a simple pomodoro timer

You can download the completed stack here.

Create a stack that is similar to figure 1:

All the code will go inside the “timer switch” button.

local lStartTime -- when it started ticking
local lEndTime -- when it should end
local lPomodoro -- a toogle between pomodoro and break
local lPomodoroCount -- how many pomodors have been done.

on mouseup
   if "start" is in the label of me then
      startTimer
   else
      stopTimer
   end if
end mouseup

on startTimer
   -- set pomodoro values
   put the seconds into lStartTime
   put the seconds + (25 * 60) into lEndTime
   set the textcolor of field "clock" to red
   put "pomodoro" into lPomodoro
   set the label of me to "Stop Pomodoro"
   put 1 into lPomodoroCount
   -- start ticking ...
   send "tictac" to me in 500 millisecs
end startTimer

on stopTimer
   put "stop" into lPomodoro
   set the label of me to "Start Pomodoro"
end stopTimer

on tictac
   -- check if the user pressed stop
   if "stop" is in lPomodoro then
      exit tictac
   end if
   -- compute how many time left
   put lEndTime - the seconds into tTime
   put tTime div 60 into tMinutes
   -- pretty print the numbers
   if the len of tMinutes < 2 then
      put 0 before tMinutes
   end if
   put tTime mod 60 into tSeconds
   -- pretty print the numbers
   if the len of tSeconds < 2 then
      put 0 before tSeconds
   end if
   -- display clock and pomodoro count
   put tMinutes & ":" & tSeconds into field "clock"
   put "Pomodoro Count:" && lPomodoroCount into field \
         "status"
   -- check if the timer reached zero
   if (tMinutes + tSeconds) is 0 then
      -- check we're on a pomodoro or break.
      if lPomodoro is "pomodoro" then
         answer info \
               "Good Work! Take a break or task completed?"\
 with "Task Completed" and "Take a break"
         if it is "Take a break" then
            put "break" into lPomodoro
            set the textcolor of field "clock" to green
            put the seconds into lStartTime
            get word -1 of field "status"
            -- we need to take a break, check if it is
            -- the long or short one.
            if it mod 4 is 0 then
               put the seconds + (15 * 60) into lEndTime
            else
               put the seconds + (5 * 60) into lEndTime
            end if
         else
            -- task completed! stop timer and log how
            -- many pomodoros we used in field "tasks"
            stopTimer
            put cr & "Task completed in" && word -1 of \
                  field "status" && "pomodoros." & cr after field "tasks"
            put "-----------" & cr after field "tasks"
         end if
      else
         -- the break is over, set the values for the
         -- new pomodoro
         answer info "Back to work?"
         put "pomodoro" into lPomodoro
         set the textcolor of field "clock" to red
         put the seconds into lStartTime
         put the seconds + (25 * 60) into lEndTime
         add 1 to lPomodoroCount
      end if
   end if
   -- rinse, repeat ...
   send "tictac" to me in 500 millisecs
end tictac

The code is commented and easy to understand. We use a script local variable “lPomodoro” to check if we’re on a pomodoro or break interval. We use a send in time loop to display the timer. When the timer reaches zero we switch from pomodoro to break or from break to pomodoro. At the end of every pomodoro, we ask the user if the task was completed. If so, we log the data to the “Tasks” field. The Pomodoro timer is red and the Break timer is green.

Usage & Conclusion

This is simple stack but it is useful. It serves as training wheels for those that are just learning about the pomodoro technique. Type your task in the tasks field along with your guesstimate. Press “Start Pomodoro” and work away for 25 minutes, take a break and repeat. The pomodoro technique is a wonderful way to work. As you learn more about it, you can tweek this little timer to add more advanced features or you may switch to a third-party timer or you may just copy Francesco and use a kitchen timer and paper. No matter what your choice is, you just discovered a powerful tool to aid your productivity.

It took two pomodoros to write this little stack…

About the Author

Andre Alves Garzia lives in Brazil. He is usually coding something network related and created RevOnRockets. When not working, he enjoys SF Books, sailing and making pizza.

 

Main Menu
on revUp today
Web or Mobile?
RPG Toolkit
AirLaunch
Pomodoro Technique

What's New

Get the 2012 Simulcast