重構類型與範例參考: https://docs.microsoft.com/zh-tw/visualstudio/ide/refactoring-in-visual-studio?view=vs-2017
這裡提供程式碼練習案例,可以參考上述網址的操作說明或後述的錄影操作示範。
(其中有改寫幾個案例,每一個案例均可透過 Console 程式執行。)
幾個常用重構類型的簡單說明與操作錄影教學:
- 變更方法簽章 (Change Method signature)
https://www.facebook.com/groups/softthinking/permalink/967175543488016/ - 重新命名 (Rename Code Symbol)
https://www.facebook.com/groups/softthinking/permalink/967471483458422/ - 提煉方法 (eXtract method)
https://www.facebook.com/groups/softthinking/permalink/967803100091927/ - 提煉介面 (eXtract interface)
https://www.facebook.com/groups/softthinking/permalink/967803100091927/ - 封裝欄位 (encapsulate field)
https://www.facebook.com/groups/softthinking/permalink/996919480513622/ - 移除暫存變數 (inline temporary variable)
https://www.facebook.com/groups/softthinking/permalink/997501143788789/ - 使用明確的型態 (explicit type)
https://www.facebook.com/groups/softthinking/permalink/998442383694665/