版权所有:内蒙古大学图书馆 技术提供:维普资讯• 智图
内蒙古自治区呼和浩特市赛罕区大学西街235号 邮编: 010021
丛 书 名:Addison-Wesley Signature Series
版本说明:1
I S B N:(纸本) 9780321146533
出 版 社:Addison-Wesley
出 版 年:2002年
主 题 词:Programming Methodology Quality Control Testing - Programming General Software Engineering
摘 要:From the Book: Clean code that works is Ron Jeffries pithy phrase. The goal is clean code that works, and for a whole bunch of reasons: Clean code that works is a predictable way to develop. You know when you are finished, without having to worry about a long bug trail. Clean code that works gives you a chance to learn all the lessons that the code has to teach you. If you only ever slap together the first thing you think of, you never have time to think of a second, better, thing. Clean code that works improves the lives of users of our software. Clean code that works lets your teammates count on you, and you on them. Writing clean code that works feels *** how do you get to clean code that works Many forces drive you away from clean code, and even code that works. Without taking too much counsel of our fears, here s what we dodrive development with automated tests, a style of development called Test-Driven Development (TDD for short). In Test-Driven Development, you: Write new code only if you first have a failing automated test. Eliminate duplication. Two simple rules, but they generate complex individual and group behavior. Some of the technical implications are: You must design organically, with running code providing feedback between decisions You must write your own tests, since you can t wait twenty times a day for someone else to write a test Your development environment must provide rapid response to small changes Your designs must consist of many highly cohesive, loosely coupled components, just to make testing easy The two rules imply an order to the tasks ofprogramming: 1. Redwrite a little test that doesn t work, perhaps doesn t even compile at first 2. Greenmake the test work quickly, committing whatever sins necessary in the process 3. Refactoreliminate all the duplication created in just getting the test to work Red/green/refactor. The TDD s mantra. Assuming for the moment that such a style is possible, it might be possible to dramatically red