DevilKing's blog

冷灯看剑,剑上几分功名?炉香无需计苍生,纵一穿烟逝,万丈云埋,孤阳还照古陵

0%

TDD change developer life

原文链接

Test-driven development is a great technique to add to your tool belt, it will help you by:

  • Giving you confidence so you can refactor
  • Improving your design towards SOLID — Forcing the code to be designed in a testable manner.
  • Develop faster over the long run.
  • Give you an easy way to retest the application in a matter of seconds.
  • Minimise YAGNI (You aren’t gonna need it) — As developers have clear goals to know when the task is done.
  • Maintenance costs reduced.

关于重构的时候,先去做TDD,很有好处

TDD rules:

  • You shall not write production code other than to pass a failing test
  • You shall not write more of the production code than necessary to pass that failing test.
  • You shall not write more of the test than to make it fail for the right reason.

TDD works greatly when you have a domain, something you know the input and what is the expected output.

针对领域编程部分,TDD效果很好