Snake Case
スネークケースは単語を小文字にしてアンダースコアでつなぐ記法である(例:user_name)。Python、データベースのカラム名、JSON で広く使われる。
目的
大文字小文字を区別しない環境に適した、読みやすい複数単語識別子の命名スタイルを提供する。
メカニズム
単語を小文字化してアンダースコアで連結する。例えば "UserName" → "user_name" となる。Python、Ruby、SQL、C の関数名で一般的である。ケバブケース(ハイフン区切り)と似ているが、アンダースコアを使う点が異なる。
ユースケース
- Python で変数や関数に名前を付ける
- データベースのカラム名
- JSON のキー名
- C/Rust の関数の名付け
例
- 入力
UserNameOutputuser_nameJoined with underscores
よくあるエラー
- Mixing with kebab-case causes inconsistent style
- Standardize the naming style across the project