--- robots: noindex, nofollow tags: refactoring --- # Repeated Switches  ## 徵兆與症狀 你發現類似 switch 結構在程式碼裡面一直重複出現。 ## 出現原因 通常 switch 結構不會只出現一次,當新的條件增加的時候,你得要找出所有的 switch 並且修改它們。當你在物件導向的程式語言重複使用到 switch 時,都應該想一想多形。 ## 處理方法 - 以往大家總是會積極的想要用 `Replace Conditional with Polymorphism` 來消滅 switch 結構,但這幾年程式語言持續在發展,switch 結構並沒有想像中恐怖,持續反覆出現 switch 結構才需要認真關注。
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up