What’s worse? TDD does badly? Or TLD done badly?

What’s worse? TDD does badly? Or TLD done badly? Which one causes MORE damage?

When talking about TDD, we always refer to TDD being done well.. whereas when we talk about TLD we talk about just the worst-case. Isn’t that an unfair comparison?

Yes, we should compare worst-case TDD and worse-case TLD. Let’s see which one is worse.

WORST CASE TDD

Worse-case TDD is when developers don’t follow the Red-Green-Refactor cycle, but instead they just omit Refactor and do ONLY Red-Green. The result is – yes, we have tests, and yes the code is testable. BUT unfortunately, aside from testability, all other aspects of good design are missing, the design is really bad!

This occurs whereby someone mindlessly for each requirement writes the test, writes the code to make the test pass, BUT doesn’t ever stand-back and look at the code and thinking about how to refactor it. Instead they just keep on adding to the existing design, without improving it. So then the design stagnates, and then starts rotting… For example, for each test case, someone decided to keep extending an endless if-statement instead of thinking about design patterns, and the code becomes unmaintainable, duplicated code, etc…

WORST CASE TLD

Worst-case TLD is when developers “just code”, so they churn out code, don’t pay attention to testability, manually debug code because they don’t have time for tests. They see tests as inferior, as secondary, as beneath them. Their job is just coding, right? I mean, if they wrote the code, and ran it in the debugger and it works, then are tests really needed?

These developers theoretically know they “should” have tests (because some famous people in software craftsmanship said that you should write tests), but for them it’s a formality, they will do the tests AFTER the code, because the code is what’s most important. The tests are there just to satisfy some minimal code coverage that the Engineering Director set for the company.

By the time they get to actually writing the tests, they can feel the pain. Tests become so painful, so cumbersome, so time-consuming, such a waste of time! And the tests would actually force them to change the design.. So then, they complain to the management that tests take up so much time, and why should tests be written for something that works, after all they can work on the next functionality. And then the tests are written… never.

SUMMARY

– In worst-case TDD, we are guaranteed to have automated tests, that code is fully covered by the tests, that code is testable BUT other aspects of the design might not be done well if the Refactor step was skipped. But the good news is, we can improve the design because we have the safety net provided by tests.

– In worst-case TLD, we will neither have automated tests nor will the code be testable. No tests, no refactoring possible. We stuck.

In summary, TDD is better than TLD even in the worst-case.

No alternative text description for this image

Optivem Group LLC 30 North Gould Street Sheridan, WY 82801 United States

Optivem DOO, MB 21609722, PIB 112111924, Heroja Maričića 93, Kraljevo 36000, Serbia

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.