スネーク‐ケースとは? わかりやすく解説

Weblio 辞書 > 辞書・百科事典 > デジタル大辞泉 > スネーク‐ケースの意味・解説 

スネーク‐ケース【snake case】

読み方:すねーくけーす

コンピューターで、スペース空白)を入れず複合語表記する際、下線記号アンダースコア)を用い方式プログラミング言語ファイル名ハッシュタグなどに用いられる。名称は、文字列ヘビスネーク)のように見えることから。スネーク記法。→キャメルケースチェーンケース

[補説] write_your_nameのように、空白下線置き換えて表す。


スネークケース

出典: フリー百科事典『ウィキペディア(Wikipedia)』 (2024/11/08 06:07 UTC 版)

Linuxのカーネルモジュールのコードの一部より。識別子にスネークケースを用いている

スネークケース(snake_case)とは、単語間の区切りをスペースの代わりにアンダースコア(_)を使い、全て小文字で記述する命名規則である。変数名やサブルーチン名、ファイル名など、コンピュータ業界で一般的に使用される。ある研究によると「読者はキャメルケースよりもスネークケースの値(value)をより早く認識できることがわかった」としている。しかし、その読者は主にアンダースコアスタイルで訓練されていたため、どちらが優れているかは実際の所は定かではない[1]

歴史

単語の区切り文字としてアンダースコアが使用されるようになったのは、1960年代後半にまで遡る。これは特にC言語に関連しており、『The C Programming Language』(1978)にも見られるスタイルで、「パスカルケース」(キャメルケースの一種) と対比されている。ただし、このスタイルには従来、特定の名前は付いていなかった。2001年にリリースされたPythonコーディング規約の決定版「PEP8」では、単に「lower_case_with_underscores」と呼ばれていた[2]

「snake_case」という用語の初出は、2004年のUsenet内のRubyコミュニティで[3]、Gavin Kistner が以下のようなコメントにおいて使用した。

ところで…この命名スタイルをお前らなんて呼んでる?スネークケースか〜?誰かが直してくれるまで俺はこう呼ぶことにするよ。

しかし、元IntelエンジニアのJack Dahlgrenによると、2002 年にIntel社内で (そしておそらくはMicrosoftエンジニアとの会話の中で)この用語を使用していたとのこと[4][出典無効]。ひょっとすると、この用語は複数のコミュニティにおいて独自に生み出されたのかもしれない。

2015年現在、複数の単語からなる識別子区切り文字で区切るような命名規則の名前は標準化されていないが、リスプケース(lisp-case)、ケバブケース(kebab-case)、スクリーミングスネークケース(SCREAMING_SNAKE_CASE)など、一部の用語に関しては使用される機会は増えている[5][6][7]

用例

以前よりスネークケースを使用しているプログラミング言語のリスト

  • ABAP[8]
  • Ada - なお頭文字は大文字[9]
  • C++ - Boost C++ライブラリ[10]
  • C - 標準ライブラリの一部の型名には使用されるが、関数名には使用されない。
  • Eiffel - クラスと特性(フィーチャー)名[11]
  • Elixir - アトム、変数、関数名[12]
  • Erlang - 関数名[13]
  • GDScript - 変数名と関数名[14]
  • Java - static final定数と列挙型に SCREAMING_SNAKE_CASE を使用する[15]
  • Kotlin - 定数に SCREAMING_SNAKE_CASE を使用 [16]
  • Magik
  • OCaml - 値、型、モジュール名[17]
  • Perl - レキシカル変数とサブルーチン[18]
  • Oracle SQL and PL/SQL - [19] for all unquoted identifiers (tables, columns, indexes, constraints, PL/SQL variables, constants, procedures/functions, triggers,...), although not official by Oracle itself, still recommended by the majority of known "influencers" and used throughout the official Oracle documentation
    • All unquoted snake_case identifiers are actually internally represented as SCREAMING_SNAKE_CASE identifiers.
  • Prolog - for both atoms (predicate names, function names, and constants) and variables[20]
  • Python - for variable names, function names, method names, and module or package (i.e. file) names[2]
  • PHP - uses SCREAMING_SNAKE_CASE for class constants
  • R - for variable names, function names, and argument names, especially in the tidyverse style[21]
  • Ruby - for variable and method names[22]
  • Rust - for variable names, function names, method names, module names, and macros[23]
  • Tcl
  • Terraform - for resources and variables[24]

関連項目

参照

  1. ^ Sharif, Bonita; Maletic, Jonathan I. (2010). “An Eye Tracking Study on camelCase and under_score Identifier Styles”. 2010 IEEE 18th International Conference on Program Comprehension. pp. 196–205. doi:10.1109/ICPC.2010.41. ISBN 978-1-4244-7604-6. http://www.cs.kent.edu/~jmaletic/papers/ICPC2010-CamelCaseUnderScoreClouds.pdf 
  2. ^ a b van Rossum, Guido; Warsaw, Barry; Coghlan, Nick (2001年7月5日). “PEP 0008 -- Style Guide for Python Code”. 2023年8月9日閲覧。
  3. ^ Gavin Kistner (23 February 2004). "Appropriate use of camelCase". Newsgroupcomp.lang.ruby. Usenet: HBn_b.379957$xy6.2073499@attbi_s02. 2015年8月13日閲覧
  4. ^ What is the history of the term "snake case" (snake_case)?”. Quora (2013年5月10日). 2023年8月9日閲覧。
  5. ^ StackOverflow – What's the name for snake_case with dashes?”. 2023年8月9日閲覧。
  6. ^ Programmers – If this is camelCase what-is-this?”. 2016年11月5日時点のオリジナルよりアーカイブ。2016年11月5日閲覧。
  7. ^ Camel_SNAKE-kebab”. GitHub (23 April 2020). 2023年8月9日閲覧。
  8. ^ Naming Conventions in ABAP Objects”. help.sap.com. 2020年7月28日閲覧。
  9. ^ Ada Programming Guidelines”. 2021年12月19日時点のオリジナルよりアーカイブ。2021年12月19日閲覧。
  10. ^ Boost Library Requirements and Guidelines”. 2015年8月13日閲覧。
  11. ^ Eiffel Class and Feature Names” (28 December 2019). 2023年8月9日閲覧。
  12. ^ Elixir Style Guide”. GitHub (May 2020). 2023年8月9日閲覧。
  13. ^ Programming Rules”. 2017年8月11日閲覧。
  14. ^ GDScript Style Guide”. 2023年8月9日閲覧。
  15. ^ Code Conventions for the Java Programming Language – Naming Conventions”. Oracle. 2021年8月3日閲覧。
  16. ^ Coding Conventions”. 2023年2月3日閲覧。
  17. ^ Xen wiki”. 2017年3月15日閲覧。
  18. ^ Damian Conway (2005). Perl Best Practices. O'Reilly Media Inc.. p. 44. ISBN 978-0596001735. https://archive.org/details/perlbestpractice00conw 
  19. ^ Quick Guide to Some Sources for Naming Conventions for Oracle Database Development”. stevenfeuersteinonplsql.blogspot.com. 2020年12月30日閲覧。
  20. ^ Michael A. Covington; Roberto Bagnara; Richard A. O'Keefe; Jan Wielemaker; Simon Price (2009). "Coding Guidelines for Prolog (v.3)". p. 14. arXiv:0911.2899 [cs.PL]。
  21. ^ Wickham, Hadley. The tidyverse style guide. http://style.tidyverse.org/ 
  22. ^ Ruby · Naming Convention”. namingconvention.org. 2023年8月9日閲覧。
  23. ^ Naming – Rust API Guidelines”. 2023年8月9日閲覧。
  24. ^ Terraform Naming Conventions” (Feb 2022). 2023年8月9日閲覧。

外部リンク



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

スネーク‐ケースのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



スネーク‐ケースのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
デジタル大辞泉デジタル大辞泉
(C)Shogakukan Inc.
株式会社 小学館
ウィキペディアウィキペディア
All text is available under the terms of the GNU Free Documentation License.
この記事は、ウィキペディアのスネークケース (改訂履歴)の記事を複製、再配布したものにあたり、GNU Free Documentation Licenseというライセンスの下で提供されています。 Weblio辞書に掲載されているウィキペディアの記事も、全てGNU Free Documentation Licenseの元に提供されております。

©2025 GRAS Group, Inc.RSS