|
|
|
|
|
by jasonlotito
5375 days ago
|
|
You forgot a critical step. Refactoring. Refactoring is a critical part of TDD, one which many people seem to forget. > It's needless context switching when I have a general idea of how I want the code structured before I start writing anyway. That's good. You are allowed to have that. In fact, your first test is implementing initial parts of that code. What TDD is force you to document that in a formal manner. It also highlights where things become cumbersome. If it's hard to write a test, your code is probably far too complex for what it's trying to do. Finally, knowing what you want is different then having what you need. TDD gives the opportunity to focus on getting a finalized code base faster by not having to implement things that are unnecessary. But really, when you describe TDD as write failing test, then write code to pass the test, and leave it at that, you've left out an essential pieces of the steps that is just as important as writing the test and writing the code. It's akin to me describing TDD as writing code and then refactoring, and leaving out testing. |
|