Introduction
Test Driven Development (TDD) has been a part of the developer's term that I view it as an arcane art for me.
As a love or hate relationship between the developer who swears by it exclusively to you don't need this attitude.
Which is similar to adopting Agile software management practices for an organisation.
I found out about it more as I became involved in helping to guide developers in Python for a developer gym organised by Junior Developer Singapore.
Besides trying out tutorials or reading books like Clean Code, Python Testing With PyTest & Test Driven Python.
Benefits of Adopting TDD
Here are the benefits I had gotten while I was helping out in developer gym that helped me in adopting the practice.
As part of my personal developer workflow in the startup, I am currently in.
The benefits I founded are as follows:
- Sanity check - Allows you to add new features, refactoring or upgrading without doubting yourself
- Reduce debugging time - by spending lesser time to find the error's root cause.
- Instill confidence in your code - Helps a lot on handing over your code base to another developer.
Who is maintaining or integrating it to their own besides your documentation
Lesson Learnt in Adopting
It Works Across Programming Languages
I will save you the religious wars over why x programming language over y programming language is better.
Despite testing frameworks or libraries differ vastly from each programming language but by knowing TDD.
It could help you transfer your understanding of writing test cases and TDD to another developer even if he/she is using a different language.
This was something I had learnt while helping to guide developers in one of the sessions of developer gym.
Speed Up Development Process
I believe that by learning TDD, it helps you to code faster.
Simple when your writing code without test cases, how long do you spend your time in fixing bugs?
Does it take from 5 minutes - 3 hours to fix a bug? Plus you might need to take your time to manually go through your program part by part to figure it out and resolve the bug
By writing test cases, you know within reason that the error did not occur in a part of your code.
Instead, with pinpoint accuracy, you find out which code is not performing according to your test cases.
Due to the code that you had introduced earlier.
Challenges Your Assumptions and Become Self Aware
In practice by adopting TDD, you become more self-aware of the problem and by failing your way towards solving the problem through your test cases.
Since through writing test cases, it allows you to gain instant feedback of code you write to solve your problem before writing your actual program in the first place.
This provides you with many test cases you had created to check if the assumption you had in your code is correct while writing your actual code.
Which means the need for you to constantly refactor & optimise your test cases to fit the solution you have in mind to solve the problem you are creating to solve.
Conclusion
Overall learning TDD helped me, to spend much lesser time debugging my code.
Instead, it had forced me to focus on formulating a solution for test cases to gain an understanding and challenging my assumptions to craft better solutions.
By failing my way with a workable solution with the problem I'm given that is reflected in my code.
This allowed me a much better appreciation of TDD and had helped me a lot.
While guiding developers who are not using my language to work on solving code katas in developer gym sessions by Junior Developer Singapore.
If you like my article, please sign up for Max Adventurer's Newsletter for awesome content I stumble across weekly in Python, Startup and Web Development.
You can also follow me to get the latest update of my article on Dev
This post was originally posted on Max's blog at Lesson In Adopting Test Driven Development (TDD) - Read Time: 3 Mins
and Photo by Louis Reed on Unsplash
Top comments (0)