If you compare the TDD version of the code to the non-TDD version, you'll see that the TDD one has much more code, but in lots of really small methods.
In six months, when it comes time to alter this code , you can make changes with confidence.
The method names in TDD code describe an atomic operation, so when a test fails, you understand what you've broken more quickly.
methods 的命名就已經描述了這個動作(atomic operation),所以當測試失敗時,你很快就能知道發生什麼事了。
If something breaks, you will know within a few lines of code what's wrong.
儘量讓 method 小而簡單,可以增加程式的可讀性。
If you find yourself writing embedded comments within methods, your method should be more refined.
如果你的 method 裡有註解,那表示,你的 method 應該要重新設計了。
沒有留言:
張貼留言