TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Test-Last Development

2 点作者 gus_leonel4 个月前

1 comment

Ukv4 个月前
&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 未加载