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

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.
主站蜘蛛池模板: 昔阳县| 开鲁县| 昔阳县| 昌图县| 南通市| 永善县| 青龙| 历史| 昭苏县| 宽甸| 河南省| 哈巴河县| 曲阳县| 丰台区| 会东县| 鹤峰县| 吉林省| 泾阳县| 光泽县| 子洲县| 山东省| 嵩明县| 邮箱| 苏尼特右旗| 盐边县| 长治县| 弥勒县| 石渠县| 峨眉山市| 千阳县| 灵山县| 台湾省| 淅川县| 西峡县| 当涂县| 阿尔山市| 宁海县| 郯城县| 萍乡市| 凤山市| 台州市|