【公式ドキュメントを読もうシリーズ】コードの読みやすさと保守容易性を改良する
シリーズ概要
https://qiita.com/yasu_programming/items/cec66f9e8d5d571e9ce3
URL
説明
リファクタリングに関しての具体的な方法に関して書かれている。
わかりづらい変数名 -> 理解しやすい変数名
Improve the variable names in this function
複雑なif文の条件式 -> 理解しやすい関数
Simplify this code. Avoid using if/else chains but retain all function return values.
深い入れ子の条件式 -> 早期リターンによる可読性の高い関数
Rewrite this code to avoid the nested if/else statements
複数の責務が混ざっている関数 -> 責務の分離
How could the processOrder method be refactored to be more useful and easier to maintain
所感
リファクタリングの方法をGithub Copilotで対応してくれる。
解像度の高いプロンプトを渡して、いいリファクタリングをしてもらえるようにしたい。