Friday, February 22, 2008

Thursday, February 21, 2008

TDD, Unit testing and legacy code

I was watching InfoQ video where Robert C. Martin and Jim Coplien talked about TDD, Design-by-contract, architecture and many other issues.

One of Bob's arguments was that

A test driven developer does not write a line of production code until he has written a failing unit test, and no production code can be written until there is a failing unit test.

it is irresponsible for a developer to ship a line of code he has not executed in a unit test.

I think that Bob's view on TDD and unit testing is a way too narrow. I'm slightly annoyed that people don't realize that the real value of TDD and unit testing will emerge weeks, months or years after the code has been written. Couple of months ago I read a Michael C. Feathers's book Working Effectively With Legacy Code. He says that

Legacy code is simply code without tests.

Big part of software development is to maintain existing applications and add new features into them. If that code does not have unit tests, it's legacy code. Even if it was written yesterday. TDD is a great way to prevent your code from changing into legacy code. When you are tweaking legacy code, you probably can't use TDD very effectively, but still you can and should try to get that code into a test harness. Why? The purpose of those tests is not TDD. The purpose is to create tests that verify current behavior and create a safety net for you. After your changes those tests should still pass. If they don't, you've broken something.

TDD implies tests, but tests don't imply TDD.

 

Technorati Tags: ,

Wednesday, February 13, 2008

Frozen Vista task manager

I was wondering what's going on in my Vista. The laptop felt slower than usual. Ok, Vista is always slow but this time it was barely crawling. I launched the Task Manager and noticed that a program program called TrustedInstaller.exe was using 88% of my precious CPU-cycles. The speed-o-meter was stuck at 88%. And it stayed there. What the heck? The Task Manager didn't refresh automatically. Update speed was set to normal but still no updating. It was time to ask Google some questions. And like always, Google knows everything. Change the update speed to something else corrected this issue. I felt really stupid. I should have tried that without any help from Google. Half of the problem solved.

But what is TrustedInstaller.exe. I've never heard of it or seen a process like that. Even the name was suggesting that it is something you shouldn't trust at all. Maybe an evil Russian trojan-downloader or something. Certainly nothing legitimate. The process starts randomly even if I'm not installing anything. It was time to call Google again. I found out that is a part of something called "Windows Module Installer". I didn't find good description of it so I won't even try to explain here what it is or what it is doing. It seems, that among other things it tries to find solutions for unsolved problems and crashes.

Long story short , I did the following :

Start > Control Panel > Classic View > Problem Reports and Solutions > Clear Solution and Problem History > Close the control panel

Problem solved. The process is still there but now it's not bugging me anymore.