shotgun parsing
アンチパターン
parseとvalidateの処理がプログラム中に散らばっている状態
エッジケースの確認し忘れが起こる危険性がある
check漏れが起きる
定義
Shotgun parsing is a programming antipattern whereby parsing and input-validating code is mixed with and spread across processing code—throwing a cloud of checks at the input, and hoping, without any systematic justification, that one or another would catch all the “bad” cases.
どうするか?
プログラムの外部との境界で、仕様を満たしたデータ型に変換するすればいい
境界部分にparse処理を集約する
出典
『The Seven Turrets of Babel: A Taxonomy of LangSec Errors and How to Expunge Them』
http://langsec.org/papers/langsec-cwes-secdev2016.pdf
入力されたものの処理に関するバグに関する論文っぽいmrsekut.icon