I had this thought this past week that we tend to believe that if we are in motion, we are accomplishing something. That being busy somehow equals being productive. And then I started thinking about how this is almost universal. It doesn’t just impact how we program, which I’ll get to eventually, but it impacts all of our life.
Let Me Illustrate
Have you ever driven to some location and had your favorite GPS system route you multiple ways? How many of you take the route that is, according to your GPS, longer, just because the roads are 65mph instead of 45mph? Or an even better example. You hit a traffic jam and, even though ever indication is that you’ll be out of the traffic in a few minutes, you take an alternate route simply because the traffic is moving on that other road. In both cases you probably know that you won’t get to your destination any faster, in fact you may get to your destination slower, but you still opt to take the moving route instead of the one that isn’t moving or is moving relatively slowly. I’ve even heard people say… shoot I’ve even said… “I want to take this route because it moves faster.” I like FEELING like I’m getting to my destination faster even if the reality is that I’m not.
And then there is the issue of your job. How many of you have to look busy for your peers to think that you ARE busy? But as programmers, how true is that? Unless you do some kind of unskilled labor, I doubt it is true of most people who work. And yet, because we are all paid by the hour (yes, even those of you who are salaried are still trading hours for dollars) there is a perception that, somehow, if we are not in motion, we are not really working. But is that true?
I remember hearing a story about a programmer who spent half his day “staring at the ceiling” who was twice as productive as any of his peers. Why is that? Because he spent half his day thinking about the problem before he ever started writing a line of code.
I remember back in the day when I was coding on 8088 computers, a compile and link cycle could take up to 10 minutes. Because I recompile and test every time I’m made a runnable change, I had a lot of 10 minute breaks. I used this time to think about the problem I was working on. This was not intentional, it just happened naturally. I think it made me more productive than if I were just churning code all day long at the speed our computers work today.
And then there is this side project I’m working on. I tend to work on it a half hour at a time as I have time. Between my main gig that takes up 40 hours a week, and some side gigs that I have, I have a very small amount of time to work on this project. Some days I don’t work on it simply because I’m too tired. But sometimes, even when I’m not sitting in front of my computer, I’ll sit on my sofa doing nothing and think about the project. It is in those times that I figure out where I want to take the project next, or how to solve a problem I’ve run into. That time thinking, even though there is no motion, has made the resulting code that much better.
The Fallacy of Motion and Testing
I’m sure you saw this coming, but one has to ask, is it the fallacy of motion that prevents us from testing our code?
At my main gig, I have to admit, I’m bored. There are a lot of reasons for this. But one of them is that I spend a lot of time waiting for integrations tests to run to verify that my code is still working. To be clear, I have way more unit test than integration test at this point. But with the changes I’m currently making to the system, I’m more likely to find issues via the integration tests than I am from the unit tests.
Compare this to a project I’m working on for another client where I’m primarily writing new code. I’m a lot less bored. The day zips by. I FEEL more productive.
And yet, the degree of certainty I have that the code I wrote for my main gig works as I designed it to work is a lot higher than the code I’m currently writing because I have more tests.
This past week those tests actually showed me that my change wasn’t working entirely the way I wanted it to. I probably would not have found it any other way. I’m not even sure the people testing my code would have found it. They aren’t those kind of testers. And so I’ve proven to myself one more time that testing, while it feels slower, really is not just the right thing to do, but ultimately the faster thing to do.
Think about what would have happened if I didn’t have these tests in place. I would have released the code, eventually the bug would have revealed itself, and I would be left scrambling to fix the bug. As it is, I was able to fix the bug in a somewhat leisurely manner because I found it early.
And yet, I don’t FEEL productive. As much as I’m convinced that Test Driven Development is the right way to go, I still struggle with this Fallacy of Motion.
We Don’t Have Time to Test
I heard this again this past week. “When you are working on a project with a tight deadline, you can’t always test because you don’t have enough time.”
Is this the Fallacy of Motion at work again?
I would argue that it is precisely BECAUSE you are working under a tight deadline that you NEED to write test.
Think about this, you have this tight deadline. Great. So you are not going to think clearly. You are going to rush. You will write incomplete code. Your methods won’t verify input parameters. You’ll have null pointer exceptions. Your code will do what it is supposed to do, but will it not do what it shouldn’t do? How will you know? And who is going to catch the bug?
Well we know the answer to that last question. The people using your code will catch the bug. This will make you look like an idiot. You are because it is something that should have been caught. It will also mean that you’ll need to track down the problem, fix the problem, and re-deploy the software. And this is faster? Faster than what?!
Of course, “We don’t have time to do it right, but we always have time to do it over.”
Slow and Steady
So, slow down. Do things right. Remember the story of the tortoise and the hare. The race doesn’t always go to the fastest but the one who is steady and persistent. The one who doesn’t cut corners. The one who consistently produces solid code.
Other post in TDD
- Why Don't You Practice Test First Development? - February 20th, 2014
- Test Driven Specifications - February 25th, 2014
- Unit Test Structure - March 11th, 2014
- When You Really Need All Of Your NUnit Test In One Class - March 18th, 2014
- TDD Isn’t All About Testing - March 25th, 2014
- Automated Web Application Functional Testing - April 1st, 2014
- What Not To Test - April 9th, 2014
- Make Your Test Work For You - April 18th, 2014
- Don’t Comment Out That Test - April 24th, 2014
- The Proper Function of QA - May 1st, 2014
- TDD Saves Time – A Story - May 22nd, 2014
- It is called "Unit Testing" for a reason - August 28th, 2014
- Is Your Architecture Crippling Your Unit Testing? - September 4th, 2014
- Selenium Performance Improvements - October 2nd, 2014
- Technical Debt Is Inevitable - October 16th, 2014
- NUnit, Unity Dependency Injection, MOQ and Private Fields - October 23rd, 2014
- NUnit & Visual Studio - December 4th, 2014
- Software Architecture without Test Driven Development is DANGEROUS! - January 29th, 2015
- NUnit Test Code Structure - February 5th, 2015
- Excuses For Not Testing - February 26th, 2015
- Why Johnny Can't do Test Driven Development - March 5th, 2015
- Changing Habits - March 19th, 2015
- 100% Code Coverage Possible? - March 26th, 2015
- TDD Gamification - Turning Test Driven Development into a Game - April 23rd, 2015
- Run NUnit from Visual Studio - April 30th, 2015
- The Parable of The Road Line Painter - May 28th, 2015
- The Fallacy of Motion - July 23rd, 2015
- Test Driven Learning - An Experiment - March 24th, 2016
- 3 Reasons You Believe 100% Code Coverage Is Impossible - May 26th, 2016