4 ms·
Why does TDD exist? 1. We want a useful target for our software. You could design a graphical mock-up of software and design your software to fit it. Or you co
by 0xbadcafebee 4y ago
Why does TDD exist?
1. We want a useful target for our software. You could design a graphical mock-up of software and design your software to fit it. Or you could create a diagram (or several). Or you could create a piece of software (a test) which explains how the software is supposed to work and demonstrates it.
2. When we modify software over time, the software eventually has regressions, bugs, design changes, etc. These problems are natural and unavoidable. If we write tests before merging code, we catch these problems quickly and early. Catching problems early reduces cost and time and increases quality. (This concept has been studied thoroughly, is at the root of practices such as Toyota Production System, and is now called Shift Left)
3. It's easy to over-design something, and hard to design it "only as much as needed". By writing a simple test, and then writing only enough code to pass the test, we can force ourselves to write simpler code in smaller deliverable units. This helps deliver value quicker by only providing what is needed and no more.
4. Other reasons that are "in the weeds" of software design, and can be carefully avoided or left alone if desired. Depends on if you're building a bicycle, a car, or a spaceship. :-)
But as in all things, the devil's in the details. It's easy to run into problems following this method. It's also easy to run into problems not following this method. If you use it, you will probably screw up for a while, until you find your own way of making it work. You shouldn't use it for everything, and you should use good judgement in how to do it.
This is an example of software being more craft than science. Not every craftsperson develops the same object with the same methods, and that's fine. Just because you use ceramic to make a mug, and another person uses glass, doesn't mean one or the other method is bad. And you can even make something with both. Try to keep an open mind; even if you don't find them productive, others do.