Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

5
  • Could you elaborate on how off-by-one errors disappear? Are you saying that you can more quickly get your answer on whether an array's index is zero-based or one-based via testing than searching through documentation? Seems unlikely to me - I'm pretty fast on Google :) Commented Apr 8, 2011 at 16:41
  • 1
    Actually, writing TDD's an excellent way to explore an API (including a legacy codebase, for the purposes of documenting functionality). Commented Apr 8, 2011 at 17:00
  • It's also very useful if that API ever changes... You suddenly have some failing tests :-) Commented Apr 8, 2011 at 19:05
  • @Ken Pespisa, It's definitely quicker - write the code based on whether you think it's 0 or 1, run it, fix it if needed. Most of the time, you'll be right and you'd have skipped having to look it up, if you are wrong, you know within 10 seconds. Commented Apr 9, 2011 at 15:55
  • Very interesting benefit. I kind of like that. Commented Apr 9, 2011 at 23:53