Software developer blog

Test driven development and unit testing frameworks

In the last few years I've been using test driven development, and grew really accustomed to it. TDD not only helps in avoiding strange errors, it also helps in software design, implementation and enforces a pro-active approach towards debugging. At first it may seem that writing tests for each and every small part of the code is time well wasted, but in fact it is definitely worth the effort, especially if an automated unit test framework is used. As not everyone may be convinced at first, here is a quick summary about how TDD works, how it improves productivity, and what are it's pros and cons.

The work-flow starts by writing the test using an automated unit test framework, and see it fail. There are several reasons for first writing the test, and implementing the feature afterwards, but I'll get to that later. After the test fails as it should, implement the new feature, and test again. If the test still fails, fix the code, and test again. If your new feature works, but tests of earlier features fail, than see how the broken code relies on the functionality you have changed, and make sure that you fix all bugs. Once all test pass, commit your code to the version control system, and continue by writing the next test, for your next feature. It is important, that you always write only as much code, as necessary to pass the test.

@ //

JavaScript based slide show

Although I think ActionScript is a well designed language one has to admit it's numerous drawbacks: it's a proprietary format, the interpreter is a poorly written black hole of resources and it is banned from Apple devices from time to time. Few years back one of my colleagues went as far as claiming that he only needs a dual core processor, so that one core is free for working while the other one handles YouTube videos. So here is an advice from me: try to avoid using flash as long as possible. JavaScript has it's own set of drawbacks, but at least it is widely available, and with the appearance of Google's Chrome the race between browsers shifted towards improving their JS platforms significantly in terms of speed, compatibility and reliability.

There are more than a handful of websites that include a slide show of images. However most of them uses a flash based solution. As fate would have it, slide shows are a perfect example of unnecessary usage of flash. In what follows I'd like to show you how easy it is to write one in JavaScript. I will use the Prototype and frameworks for this example, but it should not take you more than a few minutes to make this work with jQuery. (I may even publish a jQuery version soon.) This is how it will look like:

The images are taken randomly from the website
of the Gallery Diabolus artist community.

@ //

Drop in, Drop out

Well... I couldn't come up with any better name for this:

My original aim was to create a website element, that provides an intuitive way to add, and remove certain things from the users inventory. I didn't really find any good use for it yet, so I decided to make it open source. (Well... you don't have many other choices with JS anyway, since obfuscators are basically useless in protecting code...) It's released under a GPL license, but if you use it be nice and drop me a comment with the link, so that I can check it out.

@ //