TDD vs Procrastination
Tags: tdd, procrastination, testing
Published: 2020-05-11 21:02:32

"This post was originally posted on [https://webcu.dev](https://webcu.dev/tdd-vs-procrastination).”


[TDD](https://en.wikipedia.org/wiki/Test-driven_development) is a software development process that offers two main benefits:
- [Self Testing Code](https://martinfowler.com/bliki/SelfTestingCode.html)
- It helps us separate interface from implementation.

One of the main benefits that I see about testing, in general, is that a well-tested code base, give confidence to the developers making changes to the software. However, TDD like any other technique or methodology is not a silver bullet. It is not always possible to implement TDD or desirable. Like almost everything in Software Development and life, it is a trade-off and it depends on each situation. Only experimenting, compiling the data, and analyzing it, could we determine what works better for us. I found really interesting these links about TDD and testing:
- [TDD is dead. Long live testing](https://dhh.dk/2014/tdd-is-dead-long-live-testing.html)
- [Why Most Unit Testing is Waste](https://rbcs-us.com/documents/Why-Most-Unit-Testing-is-Waste.pdf)
- [Is TDD Dead?](https://martinfowler.com/articles/is-tdd-dead/)  


[Procrastination](https://en.wikipedia.org/wiki/Procrastination) is a very common problem and even more in these times of pandemic. With a high rate of unemployment, it’s more important than ever to get a good preparation for the interviews. One important part of the interview preparation like Software Engineer is to refresh/update our abilities to solve interview questions related to algorithms and data structures. If you don't use trees, graphs, and similar, too often, it could be kind of difficult to get in the mood to tackle these problems. 

Sometimes I look for an exercise, I check the description, it seems not so difficult to me, but there are too many edge cases to handle, then I let it for tomorrow, tomorrow becomes next week, next week becomes next month and so on. Recently I was going down this rabbit hole but I decided to change my approach and I used TDD to solve it. I started writing a test. I 
didn't solve the exercise at that moment, but I gained momentum and I was able to complete it the same day, not next week or next month. What about if you don't feel like writing test? Just start with one, the most simple that you can. After I found the [2-Minutes Rule](https://jamesclear.com/how-to-stop-procrastinating) by James Clear, I’m trying to apply it every time I feel I’m procrastinating. We need to make the habit as easy
as possible to stick with it. If our goal, is to write tests, we should start just with one. Next time the same thing, until the habit will stick with us. 

OK, fine, but what about if you don't feel even in the mood to write a single test? Design your environment in a way that the tests will be your default. In my case I use Exercism, but there are plenty of platforms out there that can help us with this task. They provide the exercises already with a set of predefined tests and we just need to create the implementation to turn them green :).

Do you have other techniques to beat procrastination while preparing yourself for your next job opportunity? What are for you the most difficult aspects of preparing for an interview?
 
## References
- [TDD](https://en.wikipedia.org/wiki/Test-driven_development)
- [Self Testing Code](https://martinfowler.com/bliki/SelfTestingCode.html)
- [TDD is dead. Long live testing](https://dhh.dk/2014/tdd-is-dead-long-live-testing.html)
- [Why Most Unit Testing is Waste](https://rbcs-us.com/documents/Why-Most-Unit-Testing-is-Waste.pdf)
- [Is TDD Dead?](https://martinfowler.com/articles/is-tdd-dead/)  
- [Procrastination](https://en.wikipedia.org/wiki/Procrastination)
- [2-Minutes Rule](https://jamesclear.com/how-to-stop-procrastinating)