Chinaunix首页 | 论坛 | 博客
  • 博客访问: 243415
  • 博文数量: 33
  • 博客积分: 2511
  • 博客等级: 少校
  • 技术积分: 391
  • 用 户 组: 普通用户
  • 注册时间: 2008-06-06 09:24
文章分类
文章存档

2011年(3)

2010年(9)

2009年(3)

2008年(18)

我的朋友

分类: LINUX

2011-01-21 16:33:57

    * Think about what you want to do.
    * Think about how to test it.
    * Write a small test. Think about the desired API.
    * Write just enough code to fail the test.
    * Run and watch the test fail. (The test-runner, if you're using something like JUnit, shows the "Red Bar"). Now you know that your test is going to be executed.
    * Write just enough code to pass the test (and pass all your previous tests).
    * Run and watch all of the tests pass. (The test-runner, if you're using JUnit, etc., shows the "Green Bar"). If it doesn't pass, you did something wrong, fix it now since it's got to be something you just wrote.
    * If you have any duplicate logic, or inexpressive code, refactor to remove duplication and increase expressiveness -- this includes reducing coupling and increasing cohesion.
    * Run the tests again, you should still have the Green Bar. If you get the Red Bar, then you made a mistake in your refactoring. Fix it now and re-run.
    * Repeat the steps above until you can't find any more tests that drive writing new code. 
阅读(2025) | 评论(1) | 转发(0) |
给主人留下些什么吧!~~

chinaunix网友2011-03-07 13:08:34

很好的, 收藏了 推荐一个博客,提供很多免费软件编程电子书下载: http://free-ebooks.appspot.com