The thorny road to Working Software

September 29, 2007

What do you have to do to be sure your code works?

Write Code - Test Code (simple)

That’s the best case. Write Code. Test Code. The less time it takes to test the code, the more often I actually test the code. If I could test all my code in one second, I’d test after every line of code I write. Or even better: the IDE would run the tests after every line of code and inform me if something unexpected happens.

That was the ideal case. Sometimes that cycle looks more like this:

Write Code - Test Code (no automatic tests)

It takes more time to test the code. Therefore I write more code before I test it - increasing the likelyhood of doing something wrong and having to repeat the cycle. Using a good debugger may help shorten that cycle.

Interestingly the debugger isn’t needed in the ideal scenario, because it doesn’t shorten the cycle there. In some environments it’s almost impossible to live without a debugger - but you should always question the use of it. Using the debugger is always a sign that I’m not working in the ideal cycle. And instead of keep on working, thoughts about how I develop software are necessary. Dependence on the debugger may be the reason why it’s hard to create working software - even if it seems to make it easier at first glance.
Bigger projects usually add more complexity. So the cycle looks more like that:

Write Code - Test Code (Enterprise cycle)

Depending on your application and environment, Hot Code Replacement can take you to one of many places. Ideally the code is replaced and is called the next time you use your application. Sometimes you have to restart your application, because the code you changed only gets called on startup, or it needs a clean state. Other times you need to restart the server, because your changes only get executed at server startup.

Of course, sometimes Hot Code Replacement fails. If you’re lucky, your IDE will tell you. Sometimes your IDE gets confused (seems to be the permanent state of RAD) and won’t replace your code without warning. That sucks because your code changes didn’t do anything. If it happens too often, you get annoyed and decide to always restart the server - just to be sure.

Here is an example from a project I worked on:

Write Code - Test Code (Real example)

If you have to do a full circle, it takes about 3 minutes. The best case is 20 seconds, which is hardly ever the case because of the GUI framework choice.

These long waits lead to something else

Write Code - Test Code (Multitasking)

Multitasking.

This is one reason why it takes so long to create enterprise applications. It’s also a reason why it’s hard to create working software in enterprises. Very often, enterprise applications just aren’t built to be tested.

It’s also interesting to note, that so far the complexity of the application to be developed hasn’t even been mentioned.

That’s why I don’t like Application Servers.

Posted by Jerome Mueller

Leave a Reply