官术网_书友最值得收藏!

Refactoring your work

The next step of the TDD cycle is to refactor your work. This step is often the hardest, because our natural impulse can be to get straight into the next feature. Chasing green, as I like to call it: building more and more functionality is much more exciting. Refactoring, however, is much more zen.

The rule "more haste; less speed" applies to coding, just as in many other areas of life. If you skip the refactoring phase, your code quality will deteriorate. If you develop a habit of skipping refactoring, your code base will soon become difficult to work with.

It takes a lot of personal discipline to consistently refactor, but you will reap the rewards of a code base that remains maintainable as it ages.

Right now, we have some repeated code between our two tests. Let's fix that.

Test code needs as much care and attention as production code. The number one principle you'll be relying on when refactoring your tests is Don't Repeat Yourself ( DRY). Drying up tests is a phrase all TDDers repeat often.
主站蜘蛛池模板: 永和县| 徐闻县| 科尔| 惠水县| 辽阳县| 克山县| 广东省| 长兴县| 五河县| 五原县| 永春县| 新沂市| 满洲里市| 大连市| 东辽县| 女性| 台南县| 乌鲁木齐市| 阿鲁科尔沁旗| 滨海县| 新闻| 广安市| 重庆市| 平南县| 盱眙县| 黔江区| 赣州市| 邵武市| 玛纳斯县| 隆安县| 陈巴尔虎旗| 罗甸县| 吐鲁番市| 宁国市| 靖远县| 农安县| 卢氏县| 简阳市| 松桃| 辽宁省| 封开县|