DEV Community

Cover image for The benefits of TDD that go beyond the code
Raffael Eloi
Raffael Eloi

Posted on

The benefits of TDD that go beyond the code

As software developers, we are constantly faced with the task of solving problems and constructing new solutions through code. So all the time there’s something to do and in general even the small things are a sequence of a lot of steps to get the things done.
This raises important questions: Where do we begin? Which task should we prioritize for development? How can we effectively organize our thoughts to maximize productivity and maintain control over the development flow?

One of the best options to solve this issue is to use the TDD process. The TDD practice is not about tests or coverage, it can be one of the things that you win when you use that, but that’s not the main point, if you think that TDD is just about testing you misunderstood the real meaning.

The TDD can be a guide to develop the business rules needed. When we use TDD thinking about scenarios and abstractions instead of tests and coverage we can have a lot of benefits that are not only code related but also benefits even to our mental health.
Here’s some benefits that you can get using the TDD practise:

Scenarios serve as valuable guides

We always have some behaviors and scenarios to implement and the best way to start implementing is to set up an expected scenario that will force you to think in a different perspective because you need to imagine what is the best input and output for the abstraction that you are building. That’s really powerful because you start to think about business rules and abstraction instead of implementation’s details and by distancing ourselves from the small details of code we can get the big picture. When we start to develop something we should not be driven by “How” we can do it, but “What” we need because thinking in a high level of abstraction can put you in a software engineer position with an abroad vision instead of a software developer just focused on code and syntax.

You get constant feedback

Sometimes it is hard to know if the features that we are building are working correctly and we don’t get the feedback of the status until we finish. When we use TDD it can be a relief because we can divide the feature in small parts and use the scenarios as a guide. For each step of the process we get the feedback (RED, GREEN, REFACTOR) what is good for our brain mechanism of reward.

It helps you with anxiety

Almost all of the software developers have anxieties when they have to build something. It’s pretty common, we want to get things done to get another task and so on, but that’s not healthy and the TDD can help you with that. When we define that we’ll start with a scenario and we have constant feedback is a nice way to work. It gives you the feeling that you are in control and you also know that what you’re building is working.

You are able to improve your software whenever you want

As we evolve over time, our past versions become stepping stones towards better expertise and experience. It's natural to reflect on our software design and envision superior solutions compared to our previous work. However, without the practice of TDD, making changes becomes arduous and prone to disastrous outcomes.

TDD empowers developers to embrace constant change and enhance their code design at any given moment. By adhering to the "boy scout rule" of leaving the code cleaner than we found it, TDD enables a mindset of continuous improvement. This freedom to make changes instills a gratifying sense of control, especially when it allows us to challenge the status quo and strive for better solutions.

In Venkat Subramaniam's conference video, "Refactor your language knowledge portfolio - we are what we can code," he offers profound insights into how the programming language we use shapes our thoughts, and how our environment influences our growth as software developers. This prompts contemplation on how software practices, principles, and processes can impact our lives as a whole. If we fail to adopt good practices that ensure the expected behavior of our systems and neglect to make necessary changes, we are forced to accept the status quo. This acceptance can permeate into our personal lives, limiting our potential for growth and improvement.

You can divide the problem in small steps

Instead of trying to tackle all the tasks simultaneously, TDD encourages a more systematic and efficient workflow. By following TDD principles, you can enhance your development process and create small, simple components. This aligns with the famous quote by Julius Caesar, "Divide and conquer," which emphasizes the power of breaking down larger problems into smaller, more manageable ones. Adopting TDD not only helps you prioritize and focus on crucial features but also promotes an essentialist mindset, allowing you to build robust solutions step by step.

Illustration by Liz Fosslien
De um lado, uma pessoa olhando para uma escada alta, sentindo-se sobrecarregada pensando em quão grande é a escada, do outro lado, uma pessoa apenas focada no próximo passo se sentindo melhor

This publication about the benefits and perception of TDD is not a scientific study. All the information, perception and opinion is based on my experience using this practice every day.

I would like to thank Marcelo Torres and Kassio Santana who are amazing people for all their help and support during the writing process. I'm very happy to have you in my life.

In the references, I will let everyone know that it was important to consolidate the concept and value of the practice of TDD in my life.

References:

Top comments (0)