ポリモーフィズムを使ってないひどいコード設計を見たので、どうリファクタリングするべきだったのかを書いておく。 やばい匂いのするコード そのシステムでは、複数の銀行とのやりとりを行うため、銀行コードに基づいて処理を分岐していた。そうこんな風に void 入金(銀行コード, ユーザID, 金額){ if(銀行コード==0001){ // A銀行用の処理 ... } else if(銀行コード==0002){ // B銀行用の処理 ... } else { // エラー } } void 出金(銀行コード, ユーザID, 金額) if(銀行コード==0001){ // A銀行用の処理 ... } else if(銀行コード==0002){ // B銀行用の処理 ... } else { // エラー } } ここでは2つしか出してないけど、実際はもっと数が多いと思って欲しい。30個くらいはあった