November 08, 2008

Unit testing sucks

Testing is, obviously, crucial to the software development process. I am pretty sure that if I wrote a hundred lines of code without running the code even once, it probably wouldn’t do what it’s supposed to do, if it even worked at all without crashing.

So testing, in general doesn’t suck. It’s unit testing that sucks. As you probably know, otherwise you wouldn’t be reading this article, unit testing is the concept that you can write additional code to test your code. Yes, this is something only a hardcore geeky programmer could love: writing code that has no purpose except to run other code. The theory is that your unit tests can be so thorough, testing every single unit of code, that the result is a rock-solid bug-free application.

If only it actually worked as well as the theory! In practice, unit testing is a monumental waste of time. Even worse than a waste of time, the result is often lower quality software that’s harder to maintain. The problems with unit testing are as follows:

(1) It’s impossible to test all possible permutations. You might have to write an infinite number of unit tests. Unit testing advocates may point out “well, it’s better to unit test what you can.” I don’t think so. Time wasted on unit testing could instead be spent by the skilled programmer to improve the quality of his riskier code. The skilled programmer has an intuitive sense of what parts of his code are likely to cause problems.

(2) Whatever you figure out needs to be tested is stuff you would code to work correctly anyway. The bugs that have always showed up in the applications I’ve worked with are unanticipated combinations of user actions or circumstances.

(3) The most important part of the application is the user interface. That’s the part of the program that the user interacts with—programs, after all, are meant to be used by people and not by unit tests. The interface tends to be the most prone to bugs, and it’s impossible to test via unit testing because using the interface the way a real person would use it is just outside the realm of what you can code.

(4) Writing unit tests is incredibly boring. Unit testing advocates might respond, “well that’s too bad, it’s necessary.” But it’s not necessary, and forcing your programming staff to do really boring tasks results in sapping their motivation thus lowering their productivity.

(5) The biggest problem I have with unit testing is its reliance on design patterns concepts. The standard test driven software project requires you to create various application “layers,” with each layer being an interface that receives other interfaces. This allows you to create mock objects that you can substitute for real objects, allowing you to test a small piece of code in isolation from the rest of the project. In order to make your application unit testable, you must make the application a lot more complicated, and complexity introduces errors. Ironically, the unit tests, if they discover errors, are probably only discovering errors that wouldn’t have happened in the first place if you weren’t doing test driven development with overly complicated design patterns.

I know that a lot of people will remain unconvinced. They will think, “I have worked on projects with unit testing, and it has found so many bugs!” But as I said in point five above, the bugs found are often bugs that wouldn’t have been there in the first place were it not for the unit tests. And unit testing generally only finds the big bugs which would have been obvious soon enough when you ran the program.

There is also the theory that unit testing ensures that, when you change some code, it doesn’t break other code. Well that’s only true if it breaks something in a way anticipated by the unit test. But you have to ask yourself, why is your project architected in such a way that it’s so susceptible to a small code change in one place breaking code elsewhere? No, it’s not because of “tight coupling” or failure to follow object oriented design patterns. It’s because of bad planning, and bad developers who confuse unit testing with quality coding. It’s because too many developers are working on the same parts of the project. Too many programmers spoil the code just as surely as too many cooks spoil the broth. The only way to create a quality big project is to divide it up into independent small projects.

November 07, 2008

Test driven development is like ...

“Test driven development is like grammar driven literature.”

Source: Bob Walsh.

(Who is Bob Walsh? I have no idea, but that his TDD analogy is genius.)

October 28, 2008

Big buttons work

I found this blog post hilarious, yet at the same time revealing of human nature.

The author of the blog apparently has a web page with a software product he wants people to download and try out. When he replaced the subtle download link with a HUGE, UGLY, IN-YOUR-FACE graphic button that reads "Download Now", he had a very large increase in the number of downloads.

Maybe I need to add a bigger button to my online dating site?

October 17, 2008

Why new development tools lead to lousy software

A major impediment to the development of quality software is the relentless need (whether real or imagined) to constantly upgrade the development tools and adopt new technologies. The programming tools and technologies are very complicated. It takes years of using them before the programmer fully understands the best practices and knows how to avoid the traps that novice users of such products fall into.

Because of the constant upgrade cycle in the software industry, by the time there is finally widespread competency with a particular technology, it becomes time to upgrade to the latest and greatest thing, forcing everyone to throw out their hard-earned knowledge of the old products and work with new stuff that they don’t understand. The inevitable result is bad software.

There’s an evil alliance between geeks who love new technologies for the sake of their geekiness and who don’t really care if the end result is buggy software, and the providers of commercial products, such as Microsoft, who make no money unless they can obsolete the old products and force everyone to pay money to “upgrade” to new products.

I wish that people would stand up to the geeks who are constantly trying to shove this new stuff down our throats. If only people would say “no, we are not upgrading to Visual Studio 2008, Visual Studio 2005 works fine enough.” But the programmers in the trenches know that such courage would be suicidal to their career prospects. No one wants to be the programmer in 2008 who is still programming exclusively in Visual Basic 6.0.

October 13, 2008

Introduction

If you’re looking for instructions on how to set the SelectedItem property of the ASP.NET ListView control, you’ve come to the wrong blog. This is a blog about big ideas, about where the software industry is headed, and why the conventional wisdom regarding the proper way to develop software is often just plain wrong.

You see, computer programmer types like to think that they are logical thinkers, but I’ve observed that, just like in any other industry, they mindlessly follow the herd and adopt best practices like object oriented programming, unit testing, design patterns, “agile” methodologies, etc, which are all actually bad practices and lead to overpriced low-quality bug-ridden software.

* * *

(Of course there is a legitimate need for information like how to set the SelectedItem property of the ASP.NET ListView control given the poor Microsoft documentation.)