Shortly after I published my last blog entry on the complaints that developers have about writing unit test (see Do I Have to Unit Test), I came across this blog entry from Derick Bailey entitled “You Are Not Paid to Write Software”. This approached the issue of excuses for the lack of unit tests from a different angle. And one that I wholeheartedly agree with.
So let me ask those of you who are professional developers a simple question. What do you think your job is?
Is your job to write the code that your boss tells you to write?
Is you job to write the code to implement every feature that your users ask for?
Is your job to find the most efficient and effective way to move the contents of a database and put it onto the screen?
Is it to optimize the code that you’re writing to squeeze every last drop of performance from it?
I’m going to suggest that you should have answered no to every single one of those questions.
If you are a developer, your job is to solve problems. The process is supposed to go as follows: users describe the problem, you develop a solution to the problem, you deliver solution to the problem, user is happy.
Sounds almost too easy, doesn’t it :)
But there is an unspoken contract in this process. Once you have solved a problem, there is no reason why you should have to solve the problem again. You don’t want to have to solve it again. And the user has no reason to have you solve it again. Not to mention that the user doesn’t want to find out that the problem that was previously solved is back again.
So why do you not do everything in your power to keep this from happening? And what is one of the simplest steps you could take?
Write unit tests.
You see? Derrick is correct. You are not paid to write software. You are paid to solve problems. And to make sure that they stay solved. Again, what is one of the easiest ways to make sure this happens?
Write unit tests!
Keep that in mind they next time you question whether you should be writing unit tests. It’s actually not a question that should come up. Writing unit tests should be part of your job. And if it’s not, then ask yourself what you think your job really is?