-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
新舊程式對照,可以看出來在 AuthForm 和 OrderForm 的錯誤處理邏輯被拿掉了, 它們現在只是單純的驗證資料格式是否正確,錯誤回報給上層處理。 這樣做的好處,第一個是語意清楚。像 AuthForm 就成為了單純處理 pin code 輸 入的 component。至於要對 pin 碼做什麼處理 (AJAX) 以及錯誤的處理,都交給 上層決定。AuthForm 裡只剩下了處理 pin 碼格式的邏輯和介面邏輯。 第二個是有利於抽換提示介面。錯誤都交由同一層處理,這代表那個 component 可以再把錯誤處理「外包」給一個統一的處理程式,比如另一個 component 或 class。這樣要抽換也會變的簡單。 另外,正確的重構應該是 1. 發現需要重構的程式 2. 構思程式新的樣貌 3. 修改測試碼的描述,把心中的藍圖畫出來 4. 修改測試碼 5. 修改程式 在 commit 這些 changeset 的時候,其實我已經把測試碼改完也寫好了,但這裡 先把程式 commit 進來,因為這樣我比較好寫說明XD
- Loading branch information
Showing
4 changed files
with
16 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters