看板 Soft_Job 關於我們 聯絡資訊
第二篇 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
penolove: 清流 02/08 13:15
q26766: 其實不太懂你這樣跟tdd 有什麼關係,你只是寫一些東西來 02/08 17:48
q26766: 確定你的答案是對的,如此而以 02/08 17:48
vi000246: 所以樓上認為的tdd是長怎樣? 02/08 20:04
landlord: 會不會我文章排版讓他以為,我是先寫產品程式碼? 02/08 20:16
landlord: 其實看一下github commit history 的diff會比較清楚 02/08 20:16
vn509942: 感謝分享 02/08 23:52
dickstar: 推 02/10 05:30