3 ms·
When those requirements change, and they can very, very quickly, you need to rewrite your tests--fine if you don't mind spending that time.
by tarkin2 5y ago
When those requirements change, and they can very, very quickly, you need to rewrite your tests--fine if you don't mind spending that time.
- AnimalMuppet 5y agoHopefully you only need to change some of your tests. When your requirements change, and you change your code, you have two questions. First, did my code change do what is needed for the requirements change? You modify tests (or write new ones) to answer that. Second, did I break anything in the process? The remaining tests answer that.
- monocasa 5y agoI've found the flow true for some environments with extremely well defined structures for doing any work (classic backend API servers being one example), but it's definitely not true for all envs. A lot of envs have you spiking so much on just how to even approach the feature that writing tests up front is wasteful overhead.
- cgrealy 5y agoIf you are spiking, then you should be throwing away that code. Don't productionise prototypes.
- monocasa 5y agoDon't just throw untested prototypes in production, but you don't gain anything in a lot of envs by throwing away a prototype completely. You're likely to introduce additional issues by rewriting it for no reason.
- AnimalMuppet 5y agoWell, if a spike is going to become production, when it does, then write the tests (along with all the other cleanup that needs to happen if your going to turn prototype code into production).
- monocasa 5y agoYes, but that model is distinctly not TDD. You came to a design, then backfilled tests.
- AnimalMuppet 5y agoOnly if you keep the design of the spike when you convert it to production. But that should be part of the "production-izing" process, right? You convert it to a solid design instead of a quick-and-dirty hack?
- monocasa 5y agoMost of the time with this model, it's not a quick and dirty hack that is the result of spiking, but the design fleshed out with maybe stubs for a few of the low risk (to the overall design) error pathways. The whole point was getting to a design that fulfills the feature requirements but for which the contract boundaries weren't known going in.
- BurningFrog 5y agoI don't understand the alternative, unless it is to not have tests?
- pydry 5y agoThe dirty secret of our industry is that a lot of the time, we don't. It's frequently scorned but Im not so sure it's always the worst idea in the world. I've built shoddy hacked together systems that made customers happy and wasted months building heavily tested well structured code doing something nobody wants. Well engineered tests take a lot of time to build - sometimes 2x the code itself. If you've built the wrong thing youve paid 3x the cost to figure it out before going back to the drawing board. I'm a big believer in retrofitting tests once code has proven itself useful.
- Jenk 5y agoCode changes when requirements change. I don't think anyone should be surprised by that.