arithma wroteWas writing some math classes (vectors) that are highly behavioral. The behavior is well defined, so it was about getting the implementation details correctly. Followed the mathematical definitions, and then wrote test cases to see if things come out as expected. That proved to be immensely valuable as I could be sure that those classes are clean, and that further errors are sure to come from abuse of those classes not from implementation mistakes inside.
I usually do take that route now, designing for a test case, making it work, testing for the obscure. At each step I do consider the generalities, so that I don't end up rewriting at each step. I like to visualize it as an ideal implementation is some sort of shape in space, and I am pinning and lofting a surface around it, each time approximating the perfect thing more closely.
You might be interested in TDD (Test Driven Development). Check it out.