Thursday, February 10, 2005

Testing and The Tao Of Programming

This evening and yesterday evening, I came across some articles by Martin Fowler, Kent Buck and Uncle Bob J

This has really set my mind alive and thinking… Xtreme Programming huh?

Well… if I had to say something about Xtreme Programming, I’ll say that Xtreme Programming is a covert operation, mounted by pure hackers, to introduce hacking at its hackiest into coporate bodies. I’m kidding right?

Nope! I’m not. Why do I say this? Well… I first started programming on DOS, back in the day, then naturally went on to Windows, and UNIX then was like a fairy tale to me. When I finally happened upon Linux, and started using GNU tools and read The Art Of UNIX Programming by Eric S. Raymond, I was rudely awakened from my fancy world, into a world I had always wanted to be in. I suddenly started learning to program in what I would call the ‘UNIX’ way. The experience was transforming. I never really wanted to program any other way again. UNIX among other things advocates small programs that do one thing and do it well, then with the help of powerful paradigms like pipes, source, filter, drain, these small programs can then be combined in ways the author never even thought was possible.

Well, I discovered also that building programs like this, reduces programming to tool development, so that a software project results in a set of tools that can be reused latter. Truth is, I slowly learned to love the C language because I was using it like it was supposed to be used. What am I getting at? I’m getting at the fact that apparently, a lot of the things I’m seeing in XP materials (not all of them ofcourse), have been exiting in the UNIX C and Perl worlds for ages, but relegated to ad-hoc hack projects. Infact, no serious programming house would hear of such practices.

After delving into some of the XP materials, I’ve been having this sense of Déjà vu, like… wow… hackers have finally found a way to sneak our secret lives and programming practices from our personal projects back at home, into the office environment, so now, we can work the same way at home and at work… big thanks to Kent Buck and all the proponents of XP.

I worry a bit though, about why this didn’t take off much earlier, why now, and why the big noise, when really its not sooooooo new (UNIX is basically a result of Xtreme Programming, before it was called Xtreme Programming, IMOHO). I think it’s a big pity that so many of us get caught up with buzz words, and we only needed another ‘buzz word’ to awaken us to the way things should be done (as they’ve been done for a long time too), I’m not reducing the effectiveness of Xtreme Programming by calling it a buzz word, but I was always wary about it since It was buzzing around me, till I decided to find out some more. If this is of any importance, I think it’s one of the few buzz words around that merit to be a buzz word, but the danger is there that since it’s a buzz word, there’s going to be soooo much misinterpretation and misappropriation. Good thing is that at least… its here finally and is being accepted corporately, so one doesn’t really have to fight much, to introduce personal hacking practices that U KNOW works, into the work place.

Now about the topic, there’s a section in The Tao Of Programming that says:

Prince Wang's programmer was coding software. His fingers danced upon the keyboard. The program compiled without an error message, and the program ran like a gentle wind.
``Excellent!'' the Prince exclaimed, ``Your technique is faultless!''
``Technique?'' said the programmer turning from his terminal, ``What I follow is Tao - beyond all techniques! When I first began to program I would see before me the whole problem in one mass. After three years I no longer saw this mass. Instead, I used subroutines. But now I see nothing. My whole being exists in a formless void. My senses are idle. My spirit, free to work without plan, follows its own instinct. In short, my program writes itself. True, sometimes there are difficult problems. I see them coming, I slow down, I watch silently. Then I change a single line of code and the difficulties vanish like puffs of idle smoke. I then compile the program. I sit still and let the joy of the work fill my being. I close my eyes for a moment and then log off.''
Prince Wang said, ``Would that all of my programmers were as wise!''

When I first read this long ago, I used to ponder and wonder, yeah right… this is good writing but it isn’t practical. Still a part of me kept trying to strive for this kind of programming perfection. I realize one thing now. It is possible (With Test Driven Developement).

I’m not right now going to strive for the one-write-on-compile-no-error part, but the run-once-like-a-gentle-wind part is what I’m striving for. Before reading up on Unit Tests, I’ve been doing it somewhat improperly. What I’ve bee doing while coding these days is that, write small sections of code, and run them with various inputs independent of the rest of the program before I move on to the next stage. I’ve not been using Unit Test frameworks and collecting all those tests properly, but I’ve been doing it, and my code has been better, without even much need to use a debugger to debug.
I picked that up from adopting what I called earlier the ‘UNIX’ way. Well… now that I’ve learned a bit about organizing the tests more formally, I’m going to adopt it, its just going to be a mere scripting of what I’ve been already doing. One of the huge benefits I can see about formalizing it into the source tree is that, its going to help some other programmer latter, and that is always good.
In conclusion, I’ll say… hackers are finally taking over the world J


Post a Comment

<< Home