作者landlord (91)
看板Soft_Job
标题[心得]TDD范例第二发-Codewars kata by C#
时间Wed Feb 8 11:53:07 2017
第二篇 TDD 范例介绍文来了。
这次挑的是 Codewars 上面的 kata:
【Next bigger number with the same digits】
【kata 题目连结】
http://bit.ly/2kFUPW5
【文章传送门】
http://bit.ly/codewars-tdd
【题目说明】
You have to create a function that takes a positive integer number and
returns the next bigger number formed by the same digits:
f(12) == 21
f(513) == 531
f(2017) == 2071
If no bigger number can be composed using those digits, return -1:
f(9) == -1
f(111) == -1
f(531) == -1
【重点】
这一篇文章针对 TDD 过程中,怎麽「刻意简单」做了些着墨,以及详细解说几个连续的
小范围重构技巧,包含:
① inline variable 消掉不必要的变数
② introduce variable 消掉重复,以便後续重构
③ move to outer scope, 避免回圈内重复宣告
④ extract method, 抽象、避免重复、增加易读性
⑤ 消除不必要的参数(我忘记叫什麽术语了)
希望对还不太知道怎麽精准掌握
「TDD 小步快跑、baby step、即时重构与重构技巧」的朋友,能帮到一些忙,enjoy!
对敏捷开发、TDD、自动测试、.NET相关技术、技术哏、系统架构设计等议题有兴趣的朋友,
我会不定时在FB粉丝专页上分享我觉得不错的资讯,
粉丝专页:
https://www.facebook.com/91agile/
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 211.23.182.57
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/Soft_Job/M.1486525992.A.953.html
※ 编辑: landlord (211.23.182.57), 02/08/2017 11:53:35
1F:推 penolove: 清流 02/08 13:15
2F:→ q26766: 其实不太懂你这样跟tdd 有什麽关系,你只是写一些东西来 02/08 17:48
3F:→ q26766: 确定你的答案是对的,如此而以 02/08 17:48
4F:推 vi000246: 所以楼上认为的tdd是长怎样? 02/08 20:04
5F:→ landlord: 会不会我文章排版让他以为,我是先写产品程式码? 02/08 20:16
6F:→ landlord: 其实看一下github commit history 的diff会比较清楚 02/08 20:16
7F:推 vn509942: 感谢分享 02/08 23:52
8F:推 dickstar: 推 02/10 05:30