Tuesday, September 22, 2009

The power of tracking and logging

Tracking resources - time, money, code changes and whatever else - is a powerful way to improve your understanding of them. Logging is even more powerful as it's automatic tracking done by your tools for you.

The practice of tracking time for the various activities one intraprends is one of the pillar of time management. Analyzing what is sucking up precious man-months gives you a clue to eliminate the tasks that really aren't worth the effort, instead of finding them by chance or by some preconcepts you may have. Tracking your spending is the first advice a financial counselor will tell you if you experience money problems.
The concept of time tracking is also present in programming: the only sure-fire way to optimize an algorithm or an application is to profile it as the first step, and then making changes to the code which constitutes the bottleneck. While an algorithm theorical analysis produces a result expressed in O(f(n)), profiling it on real data allows the programmer even to confront different O(n log n) sorting algorithms.

At a different perspective level, tracking is present in the modern methodologies of development with tools as source control systems. Every code check-in is tracked and remains forever in the history of the codebase: no line of code is ever lost in shared directories or email folders. This type of tracking information is better named as logging.
It is very cheap for a software system, if built correctly, to conserve every chunk of data that passes on its bridge. Subversion and other vcs do exactly the process of logging any single commit, and the logs reveal useful when viewed as changesets or while generating a changelog for a new release. Project management tools like trac, built upon subversion, log every change to the tickets which report bugs and feature requests, along with the edits of the wiki pages. It is a small job paragonated to the extent of tracking Wikipedia does.
If you're talking on irc or other istant messenger, your client is probably writing logs of the conversations to disk. Every enterprise java application logs exceptions to a file or to database, too.
Having a large amount of organized data is a source of valuable information, as this logging capabilities allow to:
  • posting a conversation between developers on the wiki for further reference;
  • giving commit access to new developers knowing their commits can be rolled back;
  • listing the commits which affects a particular bug, which trac does;
  • generating a changelog file by looking at the list of commits in a particular period on a branch;
  • updating a working copy or a deployment of a php application transmitting only the modified files;
  • generating a list of the locally modified files in a few seconds to see what is being committed (svn status).
There are infinite possibilities for the usage of logged data. It is often said that every item of a project which cannot be automatically generated (like builds) should be put under version control.
Logging was once expensive, when it was done by hand on dusted registers: the data was patiently annotated during the day and it wasn't going to be useful anywhere else. Now that the information era is arrived, take advantage of the logging capabilities of your tools and never write the same thing twice when a machine can do it for you.

The image is a photo of a rinascimental ledger, used for accounting. Money transaction have a long logging tradition for fiscal purposes.

4 comments:

Luca Bernardi said...

Someone suggest to track (or log if you prefer) every mistake that you make while writing code. This data can be used by yourself to improve your skill watching the class of error that you are prone to repeat.

Giorgio said...

I wonder if this can be done automatically, but I guess it will be difficult since I write failing tests all day as part of the TDD 'red' phase.

Luca Bernardi said...

The idea of this practice is to track the type of mistakes made such as "boolean false", "called a method with parameters in wrong order" or "typo" error, etc ... so far does not marry well with the TDD philosophy.
I did some research and if you're interested in, the book "Code Complete" speaks about it.

Giorgio said...

I have the book somewhere... I'll check it out thanks!

ShareThis