Hacker News new | past | comments | ask | show | jobs | submit login

> > Writing tests before the implementation code implies that you are certain about your final API, which may or may not be the case.

> How does this myth continue to persist?

Yes indeed. TDD helps you find a nice API.




TDD encourages you to implement an overly complex API with too many possible configurations. It encourages delivery of a box of parts, rather than sub-assemblies.


IMO TDD has almost exactly zero to do with the design of your API.

You can TDD top down by writing an end to end test, and recursing TDD down each level until you get to a single unit, repeat until all inception layers of the tests pass.

You can TDD bottom up, by starting with components you'll know you'll need, working out some APIs at their level, then doing the same to piece together larger components.

Ultimately you're in control of how your API looks, and this has nothing to do with TDD itself - if you get caught up exposing a bunch of inner workings and configurations, then you're simply not designing well. It has nothing to do with TDD.

Likewise, if you get caught short with an API that's too simple, well, that has little to do with TDD either.


To my respondents, who may have read more into my comment than I intended,

I merely wished to support agentultra's claim that

> When I write tests first I am looking for an API. The tests help guide me towards a nice API.

and to counter the article author's claim that

> Writing tests before the implementation code implies that you are certain about your final API, which may or may not be the case.

I did not mean my comment to be interpreted as "using TDD will guarantee you find an nice API". If you prefer, please interpret my comment as "TDD (under certain circumstances and when used in an appropriate way) can help you find a nice API".




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: