TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Test-Last Development

2 pointsby gus_leonel3 months ago

1 comment

Ukv3 months ago
&gt; If I were to implement some feature by writing a test for it first, I&#x27;d have to have a very clear idea of exactly how the feature should behave. I&#x27;d need to have chosen a suitable name for it, worked out what parameters it should take, and what it should return. And when I came to write the function in question, I&#x27;d find that most of the hard work had been done up front, and the tough design decisions taken already, leaving me only the task of writing some relatively trivial code to make the test pass.<p>One difficulty I have with this is that, while defining everything upfront like this works nicely in well-understood domains (such as implementing pre-established business logic), elsewhere my understanding of the problem only really forms through writing code and seeing what approaches work.<p>Normally I try to keep code minimal and easy to change to start with so I can quickly refactor, and then stabilize with proper tests&#x2F;documentation&#x2F;interfaces&#x2F;extensibility as other things start relying on it. Maybe this should be a separate prototype phase, which I throw away before starting the proper TDD production version? But I&#x27;m not sure if it&#x27;s usually cleanly demarcated enough for that.<p>&gt; Of course, this assumes that the code works right now, but why wouldn&#x27;t you assume that?<p>I feel TDD has to some extent the same problem in the opposite direction: you&#x27;re writing code to pass the test, so the test becomes less useful at finding potential errors <i>and</i> logic issues with the tests may be copied over to the code.
评论 #43002411 未加载