[心得]TDD範例第二發-Codewars kata by C#
第二篇 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://www.ptt.cc/bbs/Soft_Job/M.1486525992.A.953.html
※ 編輯: landlord (211.23.182.57), 02/08/2017 11:53:35
推
02/08 13:15, , 1F
02/08 13:15, 1F
→
02/08 17:48, , 2F
02/08 17:48, 2F
→
02/08 17:48, , 3F
02/08 17:48, 3F
推
02/08 20:04, , 4F
02/08 20:04, 4F
→
02/08 20:16, , 5F
02/08 20:16, 5F
→
02/08 20:16, , 6F
02/08 20:16, 6F
推
02/08 23:52, , 7F
02/08 23:52, 7F
推
02/10 05:30, , 8F
02/10 05:30, 8F