Friday, October 05, 2007

Quick and dirty

One of the most interesting comments I ever found in source code is

I am familiar with the well known //TODO: style of comment used by Visual Studio, but QD was new to me. As I found later, QD stands for "quick and dirty" and it is basically a low quality piece of code that will cause you a lot of trouble in the future. A quick search throughout the sources revealed plenty of QD comments. It seemed someone made a way of living out of this.
But sometimes programmers gotta do what programmers gotta do and even if I don't like it, I have to be quick and dirty.

Few days ago I was working on Windows mobile and I needed to decode a string that was HTTP posted to a web server. This is best accomplished by HttpUtility.UrlDecode method. Out of luck! HTTPUtility class is not available on .Net Compact Framework.

Here is where .Net Reflector came to help. I simply decompiled UrlDecode method in .Net Framework and copy-pasted the code to mobile project. Luckily, the generated code was short and it doesn't reference a lot of other classes. I was amazed by the quality of the decompiled code. Reflector did a great job!

Yes, it was quick, it was dirty but also it was very effective. As a bonus, the code is better than any code I can possibly produce in this very short time. After all, it was tested by Microsoft QA team!

No comments: