コンテンツにスキップ

「キャメルケース」の版間の差分

出典: フリー百科事典『ウィキペディア(Wikipedia)』
削除された内容 追加された内容
m →‎命名規則一覧: 未作成記事「ローワーケース」「アッパーケース」の記事作成に必要な出典の収集が困難であると結論したため、一覧からこれらを削除。
章立てを、見出し「命名規則一覧」の他種の命名規則ページと一致するように調整。元「用途」セクション、現「適用例」セクションに存在していた「識別子」を説明する文章をノートページに保管(「識別子」ページに当該文章を移動することをノートページで提案)。伴い、出典を追加、及び既存の出典の引数を修正。Wikipedia:表記ガイド#漢字Wikipedia:表記ガイド#仮名書きに準拠。
1行目: 1行目:
[[File:CamelCase_new.svg|thumb|240px|[[ラクダ]](camel)のこぶに見えることから名付けられた]]
[[File:CamelCase_new.svg|thumb|240px|[[ラクダ]](camel)のこぶに見えることから名付けられた]]
[[image:SGMcD.JPG|thumb|240px|キャメルケースの例(シンガポールのマクドナルド店舗)]]
[[image:SGMcD.JPG|thumb|240px|キャメルケースの例(シンガポールのマクドナルド店舗)]]
'''キャメルケース'''({{lang-en-short|camel case}})は、[[英語]]の[[複合語]]や[[フレーズ]]、[[文]]をひと綴りとして、各[[単語]]の[[頭文字]]を[[大文字]]で表現することを言う<ref name=":0">{{Cite web |title=キャメルケースとは - IT用語辞典 |url=https://e-words.jp/w/%E3%82%AD%E3%83%A3%E3%83%A1%E3%83%AB%E3%82%B1%E3%83%BC%E3%82%B9.html |website=IT用語辞典 e-Words |access-date=2024-06-29 |language=ja}}</ref><ref>{{Cite web |url=https://dictionary.cambridge.org/dictionary/english/camel-case |title=camel case |access-date=2024-6-29 |publisher=Cambridge Dictionary}}</ref>。キャメルケースという命名は、全体を俯瞰すると大文字の部分が「ラクダのこぶ」のように見えることに由来する<ref>{{Cite web |title=<nowiki>Camel case - MDN Web Docs Glossary: Definitions of Web-related terms | MDN</nowiki> |url=https://developer.mozilla.org/en-US/docs/Glossary/Camel_case |website=developer.mozilla.org |date=2024-05-07 |access-date=2024-06-29 |language=en-US}}</ref><ref>{{Cite web |title=camel case - Binnenmajuskel - New entry for LEO: English ⇔ German Forums - leo.org |url=https://dict.leo.org/forum/viewWrongentry.php?idForum=6&idThread=895822&lp=ende&lang=en |website=dict.leo.org |access-date=2024-06-29}}</ref><ref>{{Cite web |title=What Is Camel Case? Meaning and Examples Explained |url=https://www.98thpercentile.com/blog/what-is-camel-case/ |website=www.98thpercentile.com |access-date=2024-06-29 |language=en}}</ref>。例えば、「camel case」をキャメルケースで表現すると、「camel'''C'''ase」または「Camel'''C'''ase」となる。
'''キャメルケース'''({{lang-en-short|camel case}})は、[[英語]]の[[複合語]]や[[フレーズ]]、[[文]]をひと綴りとして、各[[単語]]の[[頭文字]]を[[大文字]]で表現する<ref name=":0">{{Cite web |title=キャメルケースとは - IT用語辞典 |url=https://e-words.jp/w/%E3%82%AD%E3%83%A3%E3%83%A1%E3%83%AB%E3%82%B1%E3%83%BC%E3%82%B9.html |website=IT用語辞典 e-Words |access-date=2024-06-29 |language=ja}}</ref><ref>{{Cite web |url=https://dictionary.cambridge.org/dictionary/english/camel-case |title=camel case |access-date=2024-6-29 |publisher=Cambridge Dictionary}}</ref>。キャメルケースという命名は、全体を俯瞰すると大文字の部分が「ラクダのこぶ」のように見えることに由来する<ref>{{Cite web |title=<nowiki>Camel case - MDN Web Docs Glossary: Definitions of Web-related terms | MDN</nowiki> |url=https://developer.mozilla.org/en-US/docs/Glossary/Camel_case |website=developer.mozilla.org |date=2024-05-07 |access-date=2024-06-29 |language=en-US}}</ref><ref>{{Cite web |title=camel case - Binnenmajuskel - New entry for LEO: English ⇔ German Forums - leo.org |url=https://dict.leo.org/forum/viewWrongentry.php?idForum=6&idThread=895822&lp=ende&lang=en |website=dict.leo.org |access-date=2024-06-29}}</ref><ref>{{Cite web |title=What Is Camel Case? Meaning and Examples Explained |url=https://www.98thpercentile.com/blog/what-is-camel-case/ |website=www.98thpercentile.com |access-date=2024-06-29 |language=en}}</ref>。例えば、「camel case」をキャメルケースで表現すると、「camel'''C'''ase」または「Camel'''C'''ase」となる。


キャメルケースという語は[[プログラミング]]の文脈で最も一般的に使用されている<ref name=":0" />が、この語は他の分野においても広く用いられている。例えば、[[デジタルメディア]]や[[マーケティング]]においては、[[ウェブサイト]]の[[URL]]や[[ドメイン名]]の[[可読性]]を向上させるためにキャメルケースが使用されることがある<ref>{{Cite web |title=What Influence Will Capitalization In URLs Have On SEO In 2024? |url=https://jemsu.com/what-influence-will-capitalization-in-urls-have-on-seo-in-2024/ |website=JEMSU |date=2024-02-21 |access-date=2024-06-29 |language=en-US |first=Chris |last=Sams}}</ref><ref>{{Cite web |title=Editorial style update: Capital letters in websites, email addresses and hashtags |url=https://blogs.missouristate.edu/brand/2019/08/05/editorial-style-update-capital-letters-in-websites-email-addresses-and-hashtags/ |website=Brand Updates |date=2019-08-05 |access-date=2024-06-29 |language=en-US}}</ref>。また、[[ドキュメント]]やガイドラインにおいては、[[セクション (文章)|セクション名]]や章[[タイトル]]の視認性を高める目的で採用されることもある<ref>{{Cite web |url=https://www.nexedi.com/ja/contact/erp5-Guideline.In.Document.Name.Publication.Section.Is.Written.In.Camelcase |title=Guideline In Document Name Publication Section Is Written In Camelcase |access-date=2024-6-29 |publisher=Nexedi}}</ref><ref>{{Cite web |title=Pandoc User’s Guide 日本語版 — 日本Pandocユーザ会 |url=https://pandoc-doc-ja.readthedocs.io/ja/latest/users-guide.html |website=pandoc-doc-ja.readthedocs.io |access-date=2024-06-29}}</ref>。さらに、[[ブランド名]]や[[製品名]]においても、一貫性を保ちつつ視覚的に目立つ名前を作成するためにキャメルケースが用いられる<ref>{{Cite web |title=Camel Case Vs Pascal Case Vs Snake Case: What's The Difference And Why Is It Important? - Dataconomy |url=https://dataconomy.com/2023/11/03/camel-case-vs-pascal-case-vs-snake-case/ |date=2023-11-03 |access-date=2024-06-29 |language=en-US}}</ref><ref>{{Cite web |url=https://www.zinzin.com/guides/zinzin-naming-guide.pdf |title=The Art of Naming |access-date=2024-6-29 |publisher=Zinzin}}</ref>。以上のように、キャメルケースはその起源と使用目的から広範な応用が可能であり、多岐に渡る分野でその有用性が認識されている。
キャメルケースという語は[[プログラミング]]の文脈で最も一般的に使用されている<ref name=":0" />が、この語は他の分野においても広く用いられている。例えば、[[デジタルメディア]]や[[マーケティング]]においては、[[ウェブサイト]]の[[URL]]や[[ドメイン名]]の[[可読性]]を向上させるためにキャメルケースが使用されることがある<ref>{{Cite web |title=What Influence Will Capitalization In URLs Have On SEO In 2024? |url=https://jemsu.com/what-influence-will-capitalization-in-urls-have-on-seo-in-2024/ |website=JEMSU |date=2024-02-21 |access-date=2024-06-29 |language=en-US |first=Chris |last=Sams}}</ref><ref>{{Cite web |title=Editorial style update: Capital letters in websites, email addresses and hashtags |url=https://blogs.missouristate.edu/brand/2019/08/05/editorial-style-update-capital-letters-in-websites-email-addresses-and-hashtags/ |website=Brand Updates |date=2019-08-05 |access-date=2024-06-29 |language=en-US}}</ref>。また、[[ドキュメント]]やガイドラインにおいては、[[セクション (文章)|セクション名]]や章[[タイトル]]の視認性を高める目的で採用されることもある<ref>{{Cite web |url=https://www.nexedi.com/ja/contact/erp5-Guideline.In.Document.Name.Publication.Section.Is.Written.In.Camelcase |title=Guideline In Document Name Publication Section Is Written In Camelcase |access-date=2024-6-29 |=Nexedi}}</ref><ref>{{Cite web |title=Pandoc User’s Guide 日本語版 — 日本Pandocユーザ会 |url=https://pandoc-doc-ja.readthedocs.io/ja/latest/users-guide.html |website=pandoc-doc-ja.readthedocs.io |access-date=2024-06-29}}</ref>。さらに、[[ブランド名]]や[[製品名]]においても、一貫性を保ちつつ視覚的に目立つ名前を作成するためにキャメルケースが用いられる<ref>{{Cite web |title=Camel Case Vs Pascal Case Vs Snake Case: What's The Difference And Why Is It Important? - Dataconomy |url=https://dataconomy.com/2023/11/03/camel-case-vs-pascal-case-vs-snake-case/ |date=2023-11-03 |access-date=2024-06-29 |language=en-US}}</ref><ref>{{Cite web |url=https://www.zinzin.com/guides/zinzin-naming-guide.pdf |title=The Art of Naming |access-date=2024-6-29 |=Zinzin}}</ref>。のように、キャメルケースはそのから広範な応用がり、多岐に渡る分野でその有用性が認識されている。


== 歴史 ==
[[ブラッド・エブラムス]]は、[[.NET Framework]]の開発において重要な役割を果たした[[マイクロソフト]]の元[[エンジニア]]兼[[プログラム (コンピュータ)|プログラム]]マネージャーである。彼は著書『Framework Design Guidelines: Conventions, Idioms, and Patterns for Reusable .NET Libraries』の中で、.NET Frameworkの初期設計の際、名付けスタイルの議論を円滑に進めるための用語を作成したと述べている。このとき、各単語の頭文字を大文字にするスタイルは「PascalCasing」と命名され、先頭の語のみ頭文字を小文字にするスタイルは「camelCasing」と命名された<ref name=":1">[https://learn.microsoft.com/en-us/dotnet/standard/design-guidelines/capitalization-conventions Capitalization Conventions - Framework Design Guidelines | Microsoft Learn]</ref>。「PascalCasing」という命名に関しては、[[Turbo Pascal]]の[[設計者]]であり、[[.NET]]設計チームの主要なメンバーでもあった[[アンダース・ヘルスバーグ]]が、これはプログラミング言語Pascalによって普及したスタイルであるとして「PascalCasing」という用語を提案した<ref>{{Cite web |title=The Private Life of a Public API |url=https://www.moserware.com/2008/12/private-life-of-public-api.html |website=www.moserware.com |access-date=2024-06-29}}</ref><ref>{{Cite web |url=https://ptgmedia.pearsoncmg.com/imprint_downloads/informit/pdfs/MSNET_Series_Dev_FINAL_linked.pdf |title=MICROSOFT ® .NET DEVELOPER |access-date=2024-6-29 |publisher=Pearson Education}}</ref>。これらの用語の選定にあたって、特に異論は出なかったとされる<ref>{{Cite book|title=Framework Design Guidelines: Conventions, Idioms, and Patterns for Reusable .NET Libraries|edition=Second|date=2008-10-22|author1=Krzysztof Cwalina|author2=Brad Abrams|publisher=Addison-Wesley Professional|isbn=978-0321545619|page=38}}</ref><ref>{{Cite book |和書 |author1=クリストフ・ツヴァリナ |author2=ブラッド・エイブラムス |date=2009-12-28 |title=.NETのクラスライブラリ設計 <!-- 長くなるためサブタイトルは省略 --> |publisher=日経BP <!-- 奥付の記載。裏表紙は、日経BPソフトプレス --> |page=32 |isbn=978-4-89100-676-1}}</ref><!-- 『.NETのクラスライブラリ設計』は英語原著『Framework Design Guidelines: Conventions, Idioms, and Patterns for Reusable .NET Libraries』の日本語翻訳版。日本語版の文章でどのように書かれているのかは不明だが、原著の"§3.1.1 Capitalization Rules for Identifiers"におけるBrad Abramsの発言は"With Anders Hejlsberg, the original designer of Turbo Pascal, and a key member of the design team, it is no wonder that we chose the term PascalCasing for the casing style popularized by the Pascal programming language."となっている。文頭の With は Against の対義語で、「〜と同意見で」「〜に賛成して」を意味していると推察することができる。 -->。「PascalCasing」は'''[[パスカルケース]]'''({{lang-en-short|Pascal case}}<!-- 「Pascal」は固有名詞であるため、先頭を小文字にしてはならない。一方「case」は固有名詞ではないため、文頭やタイトル、アクロニムの例示以外で先頭を大文字にしてはならない。英語のキャピタライゼーションルールを参照のこと。 -->)と表記されることもある。
==キャメルケースの==
キャメルケースのスタイルの起源は1970年代に遡る<ref>{{Cite book|洋書 |title=The Art of Computer Programming |url=https://www.google.co.jp/books/edition/The_Art_of_Computer_Programming/3YpQAAAAMAAJ?hl=ja&gbpv=1&bsq=The+Art+of+Computer+Programming&dq=The+Art+of+Computer+Programming&printsec=frontcover |publisher=Addison-Wesley |date=1997 |isbn=978-0-201-03809-5 |language=en |first=Donald Ervin |last=Knuth}}</ref><ref name=":2">{{Cite book|洋書 |title=Code Complete: A Practical Handbook of Software Construction |url=https://www.google.co.jp/books/edition/Code_Complete/lohA2aY9gu0C?hl=ja&gbpv=1&bsq=Code+Complete:+A+Practical+Handbook+of+Software+Construction&dq=Code+Complete:+A+Practical+Handbook+of+Software+Construction&printsec=frontcover |publisher=Microsoft Press |date=1993 |isbn=978-1-55615-484-3 |language=en |first=Steve |last=McConnell}}</ref>。この時期、[[プログラミング言語]]の発展に伴い、[[メソッド (計算機科学)|メソッド]]名や[[変数 (プログラミング)|変数]]名の命名規則が重要視され始めた。特に、長い名前を一つの[[識別子]]として扱うために、単語境界を視覚的に表現する方法として各単語の頭文字を大文字にするキャメルケースのスタイルが考案された(この時点では「キャメルケース」という用語は存在していない)。


=== 1980年代:Pascalと「mixed-case」 ===
パスカルケースは別名、'''[[バイキャピタライゼーション]]'''({{lang-en-short|bicapitalization / bi-capitalization / BiCapitalization}})<ref>{{Cite web |title=<nowiki>bicapitalizationの意味・使い方・読み方 | Weblio英和辞書</nowiki> |url=https://ejje.weblio.jp/content/bicapitalization |website=ejje.weblio.jp |access-date=2024-06-29}}</ref><ref name="sui_style_guide">[https://docs.sui.io/style-guide Style Guide | Sui Documentation]</ref>、'''[[インターキャプス]]'''({{lang-en-short|InterCaps / internal capitalization}})<ref>{{Cite web |title=InterCaps - definition of InterCaps - synonyms, pronunciation, spelling from Free Dictionary |url=https://freedictionary.org/?Query=InterCaps |website=freedictionary.org |access-date=2024-06-29}}</ref><ref name="sui_style_guide"/>とも呼ばれることがある。頭文字に小文字と大文字を混在させるケースは'''[[ミックストケース]]'''({{lang-en-short|mixed-case}})<ref>{{Cite web |title=<nowiki>Converting Between Different Naming Conventions - Python Cookbook [Book]</nowiki> |url=https://www.oreilly.com/library/view/python-cookbook/0596001673/ch03s16.html |website=www.oreilly.com |access-date=2024-06-29 |language=en}}</ref>とも呼ばれる。一部、日本語訳して'''[[キャメル記法]]'''(きほう)<ref>{{Cite web |title=キャメルケースとは? 意味や使い方 |url=https://kotobank.jp/word/%E3%82%AD%E3%83%A3%E3%83%A1%E3%83%AB%E3%82%B1%E3%83%BC%E3%82%B9-1739364 |website=コトバンク |access-date=2024-06-29 |language=ja |last=デジタル大辞泉}}</ref>、'''[[キャメル方式]]'''(ほうしき)<ref>{{Cite web |title=<nowiki>新人コーダーに知っておいて欲しい命名規則の考え方[画像・ID・class名]</nowiki> |url=https://html-coding.co.jp/knowhow/tips/naming-rule/ |website=株式会社クロノドライブ |access-date=2024-06-29 |language=ja}}</ref>と表現されることもある。
1980年代には、[[Pascal]]や[[C言語]]などのプログラミング言語が普及し、キャメルケースのスタイルが広く用いられるようになった<ref>{{Cite book|洋書 |title=Pascal User Manual and Report |url=https://www.google.co.jp/books/edition/Pascal_User_Manual_and_Report/wCmzAAAAIAAJ?hl=ja&gbpv=1&bsq=Pascal+User+Manual+and+Report&dq=Pascal+User+Manual+and+Report&printsec=frontcover |publisher=Springer-Verlag |date=1985 |isbn=978-0-387-96048-7 |language=en |first=Kathleen |last=Jensen |first2=Niklaus |last2=Wirth}}</ref><ref>{{Cite book|洋書 |title=Oh! Pascal! |url=https://www.google.co.jp/books/edition/Oh_Pascal/tmV5QgAACAAJ?hl=ja |publisher=W.W. Norton |date=1993 |isbn=978-0-393-96399-1 |language=en |first=Doug |last=Cooper}}</ref><ref>{{Cite book|洋書 |title=C Programming Language |url=https://www.google.co.jp/books/edition/C_Programming_Language/Yi5FI5QcdmYC?hl=ja&gbpv=1&bsq=The+C+Programming+Language&dq=The+C+Programming+Language&printsec=frontcover |publisher=Prentice Hall |date=1988-03-22 |isbn=978-0-13-308621-8 |language=en |first=Brian W. |last=Kernighan |first2=Dennis |last2=Ritchie}}</ref><ref>{{Cite book|洋書 |title=Software Engineering: A Practitioner's Approach |url=https://www.google.co.jp/books/edition/Software_Engineering/bL7QZHtWvaUC?hl=ja&gbpv=1&dq=Software+Engineering:+A+Practitioner's+Approach&printsec=frontcover |publisher=Palgrave Macmillan |date=2005 |isbn=978-0-07-301933-8 |language=en |first=Roger S. |last=Pressman}}</ref>。特にPascalでは、メソッド名や変数名にキャメルケースのスタイルが推奨されていた。これは、コードの読みやすさと一貫性を向上させるためであり、特にPascalの教育的な側面が強調される中で、この命名規則が採用された。この時期、キャメルケースのスタイルは"{{lang|en|mixed case}}"と呼ばれていた<ref>{{Cite web |url=https://www.oracle.com/java/technologies/javase/codeconventions-namingconventions.html |title=Naming Conventions |access-date=2024-7-14 |website=ORACLE}}</ref>{{Efn|このJavaのドキュメントはSunによって1999年に書かれた版であり、.NETが登場する前から「mixed case」という用語が使われていたことを意味している。}}。


=== 1990年代:Javaの普及 ===
==キャメルケースの種類==
1990年代には、[[Java]]の登場により、キャメルケースのスタイルがさらに普及した<ref>{{Cite book|洋書 |title=The Java Programming Language |url=https://www.google.co.jp/books/edition/The_Java_Programming_Language/M6tQAAAAMAAJ?hl=ja&gbpv=1&bsq=The+Java+Programming+Language&dq=The+Java+Programming+Language&printsec=frontcover |publisher=Addison-Wesley |date=1998 |isbn=978-0-201-31006-1 |language=en |first=Ken |last=Arnold |first2=James |last2=Gosling}}</ref><ref>{{Cite book|洋書 |title=Effective Java |url=https://www.google.co.jp/books/edition/Effective_Java/ka2VUBqHiWkC?hl=ja&gbpv=1&dq=Effective+Java&printsec=frontcover |publisher=Addison-Wesley Professional |date=2008-05-08 |isbn=978-0-13-277804-6 |language=en |first=Joshua |last=Bloch}}</ref>。Javaでは、[[クラス (コンピュータ)|クラス]]名にアッパーキャメルケース、変数名やメソッド名にローワーキャメルケースが推奨されていた。この時期に、キャメルケースのスタイルが広く認知されるようになった。
.NETのガイドライン<ref>{{Cite web |title=フレームワーク デザインのガイドライン |url=https://learn.microsoft.com/ja-jp/dotnet/standard/design-guidelines/ |website=learn.microsoft.com |date=2024-01-27 |access-date=2024-06-29 |language=ja-jp }}</ref>{{Efn|このガイドラインページは『Framework Design Guidelines: Conventions, Idioms, and Patterns for Reusable .NET Libraries, 2nd Edition』からの抜粋であるが、Krzysztof CwalinaとBrad abramsはウェブページの直接の著者ではない。}}では、先頭の語も含めて各構成語の最初の文字を大文字にするスタイルをパスカルケース、先頭の語のみ最初の文字を小文字にするスタイルをキャメルケースとしており、プログラミングの文脈でキャメルケースと言えば後者のスタイルを指すことが多いが、場合によってはどちらもキャメルケースと呼ばれることがある。これらを厳密に区別するために、[[アッパーキャメルケース]]」や「[[ローワーキャメルケース]]{{Efn|「ローワーとい読み仮名記は、「大辞林第四版<ref>{{Cite web |title=大辞林第四版 |url=https://www.sanseido-publ.co.jp/np/detail/13906/ |website=三省堂 |access-date=2024-07-01 |language=ja-JP}}</ref>」「大辞泉<ref>{{Cite web |title=大辞泉 |url=https://daijisen.jp/ |website=大泉 |access-date=2024-07-01 |language=ja-JP}}</ref>」「日本語シソーラス第2版<ref>{{Cite web |title=日本語シソーラス 第2版 類語検索辞典 |url=https://www.taishukan.co.jp/book/b227389.html |website=大修館書店 |access-date=2024-07-01 |language=ja-JP}}</ref>」「コトバンク<ref>{{Cite web |title=ローワーキャメルケース |url=https://kotobank.jp/word/%E3%83%AD%E3%83%BC%E3%83%AF%E3%83%BC%E3%82%AD%E3%83%A3%E3%83%A1%E3%83%AB%E3%82%B1%E3%83%BC%E3%82%B9-1742496 |website=コトバンク |access-date=2024-07-01 |language=ja-JP}}</ref>」「IT用語辞典<ref>{{Cite web |title=キャメルケース |url=https://e-words.jp/w/%E3%82%AD%E3%83%A3%E3%83%A1%E3%83%AB%E3%82%B1%E3%83%BC%E3%82%B9.html |website=IT用語辞典 |access-date=2024-07-01 |language=ja-JP}}</ref>」「goo辞書<ref>{{Cite web |title=ローワーキャメルケース |url=https://dictionary.goo.ne.jp/word/%E3%83%AD%E3%83%BC%E3%83%AF%E3%83%BC%E3%82%AD%E3%83%A3%E3%83%A1%E3%83%AB%E3%82%B1%E3%83%BC%E3%82%B9/ |website=goo辞書 |access-date=2024-07-01 |language=ja-JP}}</ref>」「シマウマ用語集<ref>{{Cite web |title=キャメルケース |url=https://makitani.net/shimauma/camel-case |website=シマウマ用語集 |access-date=2024-07-01 |language=ja-JP}}</ref>」など、様々な辞書で採用されている表記である。}}」といった用語が使われることもある<ref>{{Cite web |url=https://ieeexplore.ieee.org/abstract/document/4700383 |title=A Simple Approach to Optimized Text Compression's Performance |access-date=2024-6-29 |publisher=IEEE}}</ref><ref>{{Cite web |url=https://www.osti.gov/servlets/purl/1839617 |title=Universal Utility Data Exchange (UUDEX) – Information Exchange Structures – Rev 1 |access-date=2024-6-29 |publisher=アメリカ合衆国エネルギー省}}</ref>。厳密には「パスカルケース」および「キャメルケース」は.NETの文脈で使われるものであるため、他のプログラミング言語も含め、より広範な文脈では「アッパーキャメルケース」「ローワーキャメルケース」を使う<ref>{{Cite book |title=Code Complete: A Practical Handbook of Software Construction |url=https://www.google.co.jp/books/edition/Code_Complete/lohA2aY9gu0C?hl=ja&gbpv=1&bsq=Code+Complete:+A+Practical+Handbook+of+Software+Construction&dq=Code+Complete:+A+Practical+Handbook+of+Software+Construction&printsec=frontcover |publisher=Microsoft Press |date=1993 |isbn=978-1-55615-484-3 |language=en |first=Steve |last=McConnell}}</ref>。それぞれの特徴については「[[アッパーキャメルケース]]」「[[ローワーキャメルケース]]」を参照されたい。

=== 2000年代:.NET Frameworkの標準化 ===
[[イ]][[.NET Framework]]の開発において重要な役割を果たしたの元[[エンジニア]]兼[[プログラム (コンピュータ)|プログラム]]マネージャーは著書『Framework Design Guidelines: Conventions, Idioms, and Patterns for Reusable .NET Libraries』の中で、.NET Frameworkの初期設計の際、名付けスタイルの議論を円滑に進めるための用語を作成したと述べている。この、各単語の頭文字を大文字にするスタイルは「PascalCasing」と命名され、先頭の語のみ頭文字を小文字にするスタイルは「camelCasing」と命名された<ref name=":1">https://learn.microsoft.com/en-us/dotnet/standard/design-guidelines/capitalization-conventions - | </ref>。「PascalCasing」という命名に関しては、[[Turbo Pascal]]の[[設計者]]であり、[[.NET]]設計チームの主要なメンバーでもあった[[アンダース・ヘルスバーグ]]が、これはプログラミング言語Pascalによって普及したスタイルであるとして「PascalCasing」という用語を提案した<ref>{{Cite web |title=The Private Life of a Public API |url=https://www.moserware.com/2008/12/private-life-of-public-api.html |website=www.moserware.com |access-date=2024-06-29}}</ref><ref>{{Cite web |url=https://ptgmedia.pearsoncmg.com/imprint_downloads/informit/pdfs/MSNET_Series_Dev_FINAL_linked.pdf |title=MICROSOFT ® .NET DEVELOPER |access-date=2024-6-29 |publisher=Pearson Education}}</ref>。これらの用語の選定にあたって、特に異論は出なかったとされる<ref =: /><ref>{{Cite book|和書 |author1=クリストフ・ツヴァリナ |author2=ブラッド・エイブラムス |date=2009-12-28 |title=.NETのクラスライブラリ設計<!-- 長くなるためサブタイトルは省略 --> |publisher=日経BP<!-- 奥付の記載。裏表紙は、日経BPソフトプレス --> |page=32 |isbn=978-4-89100-676-1}}</ref><!-- 『.NETのクラスライブラリ設計』は英語原著『Framework Design Guidelines: Conventions, Idioms, and Patterns for Reusable .NET Libraries』の日本語翻訳版。日本語版の文章でどのように書かれているのかは不明だが、原著の"§3.1.1 Capitalization Rules for Identifiers"におけるBrad Abramsの発言は"With Anders Hejlsberg, the original designer of Turbo Pascal, and a key member of the design team, it is no wonder that we chose the term PascalCasing for the casing style popularized by the Pascal programming language."となっている。文頭の With は Against の対義語で、「〜と同意見で」「〜に賛成して」を意味していると推察することができる。 -->。「PascalCasing」は'''[[パスカルケース]]'''({{lang-en-short|Pascal case}}<!-- 「Pascal」は固有名詞であるため、先頭を小文字にしてはならない。一方「case」は固有名詞ではないため、文頭やタイトル、アクロニムの例示以外で先頭を大文字にしてはならない。英語のキャピタライゼーションルールを参照のこと。 -->)と表記されることもある。

=== 2010年代以降:モダン言語での普及 ===
2010年代以降、キャメルケースは多くのプログラミング言語やフレームワークで一般的な命名規則として使われ続けている<ref>{{Cite book|洋書 |title=JavaScript: The Good Parts: The Good Parts |url=https://www.google.co.jp/books/edition/JavaScript_The_Good_Parts/PXa2bby0oQ0C?hl=ja&gbpv=1&printsec=frontcover |publisher="O'Reilly Media, Inc." |date=2008-05-08 |isbn=978-0-596-55487-3 |language=en |first=Douglas |last=Crockford}}</ref><ref>{{Cite book|洋書 |title=Python Crash Course: A Hands-On, Project-Based Introduction to Programming |url=https://www.google.co.jp/books/edition/Python_Crash_Course/RXoZCwAAQBAJ?hl=ja&gbpv=1&dq=Python+Crash+Course&printsec=frontcover |publisher=No Starch Press |date=2015-11-20 |isbn=978-1-59327-603-4 |language=en |first=Eric |last=Matthes}}</ref>。特に、[[JavaScript]]や[[Python]]などのモダンな言語でもキャメルケースが広く採用されている。ただし、これらは厳密には.NETの文脈に属さないため、同じスタイルでも「ローワーキャメルケース」と呼ぶ<ref name=":11">{{Cite web |title=キャメルケースとは - IT用語辞典 |url=https://e-words.jp/w/%E3%82%AD%E3%83%A3%E3%83%A1%E3%83%AB%E3%82%B1%E3%83%BC%E3%82%B9.html |website=IT用語辞典 e-Words |access-date=2024-07-01 |language=ja}}</ref><ref>{{Cite web |title=ローワーキャメルケースとは? 意味や使い方 |url=https://kotobank.jp/word/%E3%83%AD%E3%83%BC%E3%83%AF%E3%83%BC%E3%82%AD%E3%83%A3%E3%83%A1%E3%83%AB%E3%82%B1%E3%83%BC%E3%82%B9-1742496 |website=コトバンク |access-date=2024-07-01 |language=ja}}</ref>。

==文脈別の使い分け==
.NETのガイドライン<ref>{{Cite web |title=フレームワーク デザインのガイドライン |url=https://learn.microsoft.com/ja-jp/dotnet/standard/design-guidelines/ |website=learn.microsoft.com |date=2024-01-27 |access-date=2024-06-29 |language=ja-jp }}</ref>{{Efn|このガイドラインページは『Framework Design Guidelines: Conventions, Idioms, and Patterns for Reusable .NET Libraries, 2nd Edition』からの抜粋であるが、Krzysztof CwalinaとBrad abramsはウェブページの直接の著者ではない。}}では、先頭の語も含めて各構成語の文字を大文字にするスタイルをパスカルケース、先頭の語のみ文字を小文字にするスタイルをキャメルケースとしており、プログラミングの文脈でキャメルケースと言えば後者のスタイルを指すことが多いが、場合によってはどちらもキャメルケースと呼ばれることがある「キャメルケースローワーキャメルケース」う表、「<ref>{{Cite web |title=<> | 辞</> |url=https://..jp// |website= |access-date=2024-07-}}</ref>」「<ref>{{Cite web |title=キャメルケース |url=https://.jp/word/%E3%82%AD%E3%83%A3%E3%83%A1%E3%83%AB%E3%82%B1%E3%83%BC%E3%82%B9 |website= |access-date=2024-07- |language=ja}}</ref><ref>{{Cite web |title=キャメルケース |url=https://.jp//%E3%82%AD%E3%83%A3%E3%83%A1%E3%83%AB%E3%82%B1%E3%83%BC%E3%82%B9 |website= |access-date=2024-07- |language=ja}}</ref>」「ーキャメルケース」「キャメルケース」といった用語が使われる<ref>{{Cite web |url=https://ieeexplore.ieee.org/abstract/document/4700383 |title=A Simple Approach to Optimized Text Compression's Performance |access-date=2024-6-29 |=IEEE}}</ref><ref>{{Cite web |url=https://www.osti.gov/servlets/purl/1839617 |title=Universal Utility Data Exchange (UUDEX) – Information Exchange Structures – Rev 1 |access-date=2024-6-29 |=アメリカ合衆国エネルギー省}}</ref>。厳密には「パスカルケース」および「キャメルケース」は.NETの文脈で使われるものであるため、他のプログラミング言語も含め、より広範な文脈では「アッパーキャメルケース」「ローワーキャメルケース」を使う<ref =: />。それぞれの特徴については「[[アッパーキャメルケース]]」「[[ローワーキャメルケース]]」を参照されたい。


{|class=wikitable
{|class=wikitable
23行目: 35行目:
|複合語の先頭を、小文字で書き始める。
|複合語の先頭を、小文字で書き始める。
|}
|}
なお、英語で大文字は{{lang|en|upper case}}、小文字は{{lang|en|lower case}}であるが、これらは[[活版印刷]]の名残である<ref>{{Cite book |title=Type Specimens: A Visual History of Typesetting and Printing |url=https://books.google.co.jp/books?hl=ja&lr=lang_ja%7Clang_en&id=-rdREAAAQBAJ&oi=fnd&pg=PP1&dq=%22upper+case%22+%22lower+case%22+origin+%22typesetting%22+%22history%22&ots=yogW2WIhm7&sig=yil1DC2NcXyz_i6YHh2tx_UWlhc#v=onepage&q=%22upper%20case%22%20%22lower%20case%22%20origin%20%22typesetting%22%20%22history%22&f=false |publisher=Bloomsbury Publishing |date=2021-12-30 |isbn=978-1-350-11661-0 |language=en |first=Dori |last=Griffin}}</ref><ref>{{Cite book |title=Type Matters: The Rhetoricity of Letterforms |url=https://books.google.co.jp/books?hl=ja&lr=lang_ja%7Clang_en&id=EKwWEAAAQBAJ&oi=fnd&pg=PA3&dq=%22upper+case%22+%22lower+case%22+origin+%22typesetting%22+%22history%22&ots=bfzTiv_Bfp&sig=u7xhGw9f_EzJFZFIexhnETHdExY#v=onepage&q=upper%20case&f=false |publisher=Parlor Press LLC |date=2017-09-01 |isbn=978-1-60235-978-9 |language=en |first=Christopher Scott |last=Wyatt |first2=Dànielle Nicole |last2=DeVoss}}</ref>。
なお、英語で大文字は{{lang|en|upper case}}、小文字は{{lang|en|lower case}}であるが、これらは[[活版印刷]]の名残である<ref>{{Cite book |title=Type Specimens: A Visual History of Typesetting and Printing |url=https://books.google.co.jp/books?hl=ja&lr=lang_ja%7Clang_en&id=-rdREAAAQBAJ&oi=fnd&pg=PP1&dq=%22upper+case%22+%22lower+case%22+origin+%22typesetting%22+%22history%22&ots=yogW2WIhm7&sig=yil1DC2NcXyz_i6YHh2tx_UWlhc#v=onepage&q=%22upper%20case%22%20%22lower%20case%22%20origin%20%22typesetting%22%20%22history%22&f=false |publisher=Bloomsbury Publishing |date=2021-12-30 |isbn=978-1-350-11661-0 |language=en |first=Dori |last=Griffin}}</ref><ref>{{Cite book |title=Type Matters: The Rhetoricity of Letterforms |url=https://books.google.co.jp/books?hl=ja&lr=lang_ja%7Clang_en&id=EKwWEAAAQBAJ&oi=fnd&pg=PA3&dq=%22upper+case%22+%22lower+case%22+origin+%22typesetting%22+%22history%22&ots=bfzTiv_Bfp&sig=u7xhGw9f_EzJFZFIexhnETHdExY#v=onepage&q=upper%20case&f=false |publisher=Parlor Press LLC |date=2017-09-01 |isbn=978-1-60235-978-9 |language=en |first=Christopher Scott |last=Wyatt |first2=Dànielle Nicole |last2=DeVoss}}</ref>。


{{see also|大文字と小文字}}
{{see also|大文字と小文字}}


.NET Frameworkの<code>System.Xml.Serialization.CodeIdentifier</code>クラスには、[[Extensible Markup Language|XML]]の要素や属性の名前から取得されたメソッド引数などのようなコードの実体から、パスカルケース(アッパーキャメルケース)の文字列を生成するメソッド<code>MakePascal()</code><ref>{{Cite web |title=CodeIdentifier.MakePascal(String) Method (System.Xml.Serialization) |url=https://learn.microsoft.com/en-us/dotnet/api/system.xml.serialization.codeidentifier.makepascal?view=netframework-1.1 |website=learn.microsoft.com |access-date=2024-07-07 |language=en-us |author=dotnet-bot}}</ref>と、キャメルケース(ローワーキャメルケース)の文字列を生成するメソッド<code>MakeCamel()</code><ref>{{Cite web |title=CodeIdentifier.MakeCamel(String) Method (System.Xml.Serialization) |url=https://learn.microsoft.com/en-us/dotnet/api/system.xml.serialization.codeidentifier.makecamel?view=netframework-1.1 |website=learn.microsoft.com |access-date=2024-07-07 |language=en-us |author=dotnet-bot}}</ref>が当初から用意されていた。
.NET Frameworkの<code>System.Xml.Serialization.CodeIdentifier</code>クラスには、[[Extensible Markup Language|XML]]の要素や属性の名前から取得されたメソッド引数などのようなコードの実体から、パスカルケース(アッパーキャメルケース)の文字列を生成するメソッド<code>MakePascal()</code><ref>{{Cite web |title=CodeIdentifier.MakePascal(String) Method (System.Xml.Serialization) |url=https://learn.microsoft.com/en-us/dotnet/api/system.xml.serialization.codeidentifier.makepascal?view=netframework-1.1 |website=learn.microsoft.com |access-date=2024-07-07 |language=en-us |=dotnet-bot}}</ref>と、キャメルケース(ローワーキャメルケース)の文字列を生成するメソッド<code>MakeCamel()</code><ref>{{Cite web |title=CodeIdentifier.MakeCamel(String) Method (System.Xml.Serialization) |url=https://learn.microsoft.com/en-us/dotnet/api/system.xml.serialization.codeidentifier.makecamel?view=netframework-1.1 |website=learn.microsoft.com |access-date=2024-07-07 |language=en-us |=dotnet-bot}}</ref>が当初から用意されていた。

== 利点 ==
利点については、「[[ローワーキャメルケース#利点|ローワーキャメルケース]]」「[[アッパーキャメルケース#利点|アッパーキャメルケース]]」の「利点」項目で説明されている。


キャメルケースについて、利点という点で上記の利点と比較して特筆すべき点はないため、このページでは省略する。
==用==
[[File:CamelCase.svg|thumb|right|250px|CamelCase]]
[[プログラミング (コンピュータ)|コンピュータプログラミング]]において、パスカルケース(アッパーキャメルケース)やキャメルケース(ローワーキャメルケース)が[[識別子]]の[[命名規則 (プログラミング)|命名規則]]として用いられることがある<ref>{{Cite web |title=Programming Naming Conventions – Camel, Snake, Kebab, and Pascal Case Explained |url=https://www.freecodecamp.org/news/programming-naming-conventions-explained/ |website=freeCodeCamp.org |date=2022-08-22 |access-date=2024-06-29 |language=en}}</ref><ref>{{Cite web |url=https://eufemia.dnb.no/contribute/style-guides/naming/ |title=Naming convention |access-date=2024-6-29 |publisher=DNB Bank ASA}}</ref>。


== 欠点 ==
識別子とは、[[変数 (プログラミング)|変数]]、[[サブルーチン]]、およびユーザー定義データ型などの構文要素を区別するために使用される名前を指す<ref>{{Cite web |title=User Defined Data Types in C++ |url=https://www.geeksforgeeks.org/user-defined-data-types-in-c/ |website=GeeksforGeeks |date=2018-10-22 |access-date=2024-06-29 |language=en-US}}</ref><ref>{{Cite web |title=User-Defined Data Type - Visual Basic |url=https://learn.microsoft.com/en-us/dotnet/visual-basic/language-reference/data-types/user-defined-data-type |website=learn.microsoft.com |date=2021-09-15 |access-date=2024-06-29 |language=en-us |last=KathleenDollard}}</ref>。多くのプログラミング言語においては、スペースがトークン([[字句]])の区切りとして機能するため、識別子にスペースを含めることは許されない<ref>{{Cite web |title=String Tokenization in C |url=https://www.geeksforgeeks.org/string-tokenization-in-c/ |website=GeeksforGeeks |date=2023-10-18 |access-date=2024-06-29 |language=en-US}}</ref><ref>{{Cite web |title=Tokens |url=https://www.ibm.com/docs/en/i/7.3?topic=elements-tokens |website=www.ibm.com |access-date=2024-06-29 |language=en-us}}</ref>。これにより、識別子には一続きの文字列が必要となる。従って、複数の単語からなる識別子にはパスカルケース(アッパーキャメルケース)、キャメルケース(ローワーキャメルケース)、[[スネークケース]]、[[ケバブケース]](チェインケース)といった命名規則が適用され、各単語の区切りを明示する。これらの命名規則は、コードの可読性および[[メンテナンス|保守性]]を向上させ、プログラムの構造を明確にする役割を果たしている<ref>{{Cite web |title=Mastering Coding Standards and Best Practices for Software Development |url=https://www.codium.ai/blog/mastering-coding-standards-and-best-practices-for-software-development/ |website=CodiumAI |date=2024-04-17 |access-date=2024-06-29 |language=en-US |first=CodiumAI |last=Team}}</ref><ref>{{Cite web |title=Naming conventions in programming – a review of scientific literature — Makimo – Consultancy & Software Development Services |url=https://makimo.com/blog/scientific-perspective-on-naming-in-programming/ |website=makimo.com |date=2022-02-02 |access-date=2024-06-29 |language=en-US |first=Iwo |last=Herka}}</ref>。一般的な言語では、英数字のほかに[[アンダースコア]]<code>_</code>を使うことができる<ref>{{Cite web |title=Alphanumeric Characters: Uses and Examples |url=https://computer.howstuffworks.com/alphanumeric-characters.htm |website=HowStuffWorks |date=2024-02-08 |access-date=2024-06-29 |language=en-us}}</ref><ref>{{Cite web |title=Underscores in Numeric Literals |url=https://docs.oracle.com/javase/8/docs/technotes/guides/language/underscores-literals.html |website=docs.oracle.com |access-date=2024-06-29}}</ref><ref>{{Cite web |title=C Identifiers |url=https://www.geeksforgeeks.org/c-identifiers/ |website=GeeksforGeeks |date=2023-09-06 |access-date=2024-06-29 |language=en-US}}</ref>が、古い[[COBOL]]のようにアンダースコアは使えず、代わりに[[ハイフンマイナス]]<code>-</code>を使うことができるという言語もある<ref>{{Cite web |title=6.10 COBOLアプリケーション使用時の注意事項 |url=https://software.fujitsu.com/jp/manual/manualfiles/M090099/B1WN9451/07Z200/B9451-01-06-10-00.html |website=software.fujitsu.com |access-date=2024-06-29}}</ref><ref>{{Cite web |title=Research Guides: Archives and Special Collections on COBOL and the History of Programming Languages: Home |url=https://libguides.umn.edu/c.php?g=1081256&p=7880250 |website=libguides.umn.edu |access-date=2024-06-29 |language=en |first=Amanda |last=Wick}}</ref>。また、初期のコンピュータでは、容量などの制約から大文字・小文字を区別することができず、大文字のみが使える環境が主流だった<ref>{{Cite web |url=https://www.gavilan.edu/csis/languages/00-intro.html |title=Programming Language Statements Oddities: History and idiosyncrasies (or oddities) |access-date=2024-6-29 |publisher=Gavilan College}}</ref><ref>{{Cite web |title=情報学概論Ⅰ 第4回 |url=http://www2.nagano.ac.jp/hiraoka/IIn1/4.html |website=www2.nagano.ac.jp |access-date=2024-06-29}}</ref><ref>[https://gigazine.net/news/20231224-ancient-computer-all-caps/ 古いコンピュータやOSで小文字ではなく大文字が使用されていた理由とは? - GIGAZINE]</ref>。そのため、[[BASIC]]やPascalといった初期の言語では、大文字・小文字を区別しない仕様となっているものが多かった。[[C言語]]の場合、[[ANSI C]](C89)規格では、保証される外部識別子名の長さは6文字まで、内部識別子名の長さは31文字までという互換性制約があった<ref>{{Cite web |title=Hewlett Packard Company Conformance Statement |url=https://www.opengroup.org/csq/repository/noreferences=1&RID=hp%252FLL1%252F9.html |website=www.opengroup.org |access-date=2024-06-29}}</ref><ref>[https://learn.microsoft.com/en-us/cpp/c-language/c-identifiers C Identifiers | Microsoft Learn]</ref>{{efn|[[標準Cライブラリ]]の関数名が暗号のように短く分かりづらいのも、[[プログラミング言語C|K&R]]時代から続く初期の資源制約によるものである。}}。
欠点については、「[[ローワーキャメルケース#欠点|ローワーキャメルケース]]」「[[アッパーキャメルケース#欠点|アッパーキャメルケース]]」の「欠点」項目で説明されている。


キャメルケースについて、欠点という点で上記の欠点と比較して特筆すべき点はないため、このページでは省略する。
識別子に使用可能な文字種や文字数に制限のある環境において、複合語を一つのプログラム要素としたいときには「<code>getinputreader</code>」や「<code>GETINPUTREADER</code>」のように直接連結するしかない場合もある。しかし、直接連結してしまうと語の区切り(境界)を認識しにくく、[[可読性]]を欠いてしまう。アンダースコア<code>_</code>やハイフンマイナス<code>-</code>が使える環境ではそれらの文字を区切り文字に使って「<code>get_input_reader</code>」や「<code>GET-INPUT-READER</code>」などとする方法もあるが、文字数が増えてしまい、場合によっては処理系の制限に抵触してしまう。のちに大文字・小文字を区別できる環境が登場し主流となったが、後続の語の頭文字を大文字とし、文字数の増大を抑制しつつ、語の区切りを認識しやすくする記法が考案された{{efn|ただし、キャメルケースも可読性を損うとして嫌う人もいる。例えば[[C++]]の設計者[[ビャーネ・ストロヴストルップ]]は、''“{{lang|en|I prefer to use underscores to separate words in an identifier (e.g, element_count) rather than alternatives, such as elementCount and ElementCount.}}”''と述べている<ref>[https://www.stroustrup.com/bs_faq2.html#Hungarian Stroustrup: C++ Style and Technique FAQ]</ref><ref>[http://www.libjingu.jp/trans/bs_faq2-j.html#Hungarian Stroustrup: C++ Style and Technique FAQ 日本語訳]</ref>。実際に、[[標準C++ライブラリ]]には、<code>std::runtime_error</code>や<code>std::vector::push_back()</code>のように、アンダースコアを使った名前が頻出する。しかし彼は、言語組み込みのデータ型や標準ライブラリのデータ型との名前衝突を避けるため、ユーザー定義のデータ型の名前は先頭を大文字にすることを推奨してもいる。}}。この記法はのちに「キャメルケース」や「パスカルケース」として用語が再定義されることになるが、そのような用語が定義される前から{{lang|en|mixed case}}などの名前で呼ばれていた<ref>[https://www.oracle.com/java/technologies/javase/codeconventions-namingconventions.html Code Conventions for the Java Programming Language: 9. Naming Conventions]</ref>{{Efn|このJavaのドキュメントはSunによって1999年に書かれた版であり、.NETが登場する前から「mixed case」という用語が使われていたことを意味している。}}。


==用==
[[Visual Basic]]は[[Windows API]]や[[Object Linking and Embedding|OLE]]/[[Component Object Model|COM]]の影響を<ref>{{Cite book |title=Programming Windows |url=https://www.google.co.jp/books/edition/Programming_Windows/Da9CAwAAQBAJ?hl=ja&gbpv=0 |publisher=Pearson Education |date=2013-01-15 |isbn=978-0-7356-7172-0 |language=en |first=Charles |last=Petzold}}</ref><ref>{{Cite web |url=https://www.amazon.co.jp/INSIDE-Microsoft-Programming-Dale-Rogerson/dp/1572313498 |title=Inside COM |access-date=2024-6-29 |publisher=Amazon}}</ref>、また.NET Frameworkや.NET言語([[C Sharp|C#]]、[[VB.NET]]など)は[[Delphi]]([[Object Pascal]])の影響を受けており<ref>{{Cite book |title=The C# Programming Language |url=https://www.google.co.jp/books/edition/The_C_Programming_Language/ICe7ea4RscUC?hl=ja&gbpv=0 |publisher=Pearson Education |date=2008-10-08 |isbn=978-0-321-59225-5 |language=en |first=Anders |last=Hejlsberg |first2=Mads |last2=Torgersen |first3=Scott |last3=Wiltamuth |first4=Peter |last4=Golde}}</ref><ref>{{Cite book |title=Programming in the .NET Environment |url=https://www.google.co.jp/books/edition/Programming_in_the_NET_Environment/sWhAOMIf4MUC?hl=ja&gbpv=0 |publisher=Addison-Wesley Professional |date=2003 |isbn=978-0-201-77018-6 |language=en |first=Damien |last=Watkins |first2=Mark J. |last2=Hammond |first3=Brad |last3=Abrams}}</ref>、[[メソッド (計算機科学)|メソッド]]の名前を大文字で始めるアッパーキャメルケースとなっているが<ref name=":1" /><ref>{{Cite web |title=Method Naming · Programming Basics with C# - Free Coding Book with Video Lessons |url=https://csharp-book.softuni.org/Content/Chapter-10-methods/method-naming/method-naming.html |website=csharp-book.softuni.org |access-date=2024-06-29}}</ref>、[[Java]]はメソッドの名前を小文字で始めるローワーキャメルケースとなっている<ref>{{Cite web |title=Java Naming Conventions: PascalCase, camelCase, and more - CRS Info Solutions |url=https://www.crsinfosolutions.com/java-naming-conventions/#:~:text=camelCase%20(Lower%20Camel%20Case),subsequent%20starting%20word%20is%20capitalized. |website=www.crsinfosolutions.com |access-date=2024-06-29}}</ref>。ただし、いずれもユーザー定義型の名前は大文字で始めるアッパーキャメルケースである。
[[Visual Basic]]は[[Windows API]]や[[Object Linking and Embedding|OLE]]/[[Component Object Model|COM]]の影響を<ref>{{Cite book |title=Programming Windows |url=https://www.google.co.jp/books/edition/Programming_Windows/Da9CAwAAQBAJ?hl=ja&gbpv=0 |publisher=Pearson Education |date=2013-01-15 |isbn=978-0-7356-7172-0 |language=en |first=Charles |last=Petzold}}</ref><ref>{{Cite |url=https://www.amazon.co.jp/INSIDE-Microsoft-Programming-Dale-Rogerson/dp/1572313498}}</ref>、また.NET Frameworkや.NET言語#、[[VB.NET]]など)は[[Delphi]]([[Object Pascal]])の影響を受けており<ref>{{Cite book |title=The C# Programming Language |url=https://www.google.co.jp/books/edition/The_C_Programming_Language/ICe7ea4RscUC?hl=ja&gbpv=0 |publisher=Pearson Education |date=2008-10-08 |isbn=978-0-321-59225-5 |language=en |first=Anders |last=Hejlsberg |first2=Mads |last2=Torgersen |first3=Scott |last3=Wiltamuth |first4=Peter |last4=Golde}}</ref><ref>{{Cite book |title=Programming in the .NET Environment |url=https://www.google.co.jp/books/edition/Programming_in_the_NET_Environment/sWhAOMIf4MUC?hl=ja&gbpv=0 |publisher=Addison-Wesley Professional |date=2003 |isbn=978-0-201-77018-6 |language=en |first=Damien |last=Watkins |first2=Mark J. |last2=Hammond |first3=Brad |last3=Abrams}}</ref>、メソッドの名前を大文字で始めるアッパーキャメルケースとなっているが<ref name=":1" /><ref>{{Cite web |title=Method Naming · Programming Basics with C# - Free Coding Book with Video Lessons |url=https://csharp-book.softuni.org/Content/Chapter-10-methods/method-naming/method-naming.html |website=csharp-book.softuni.org |access-date=2024-06-29}}</ref>、[[Java]]はメソッドの名前を小文字で始めるローワーキャメルケースとなっている<ref>{{Cite web |title=Java Naming Conventions: PascalCase, camelCase, and more - CRS Info Solutions |url=https://www.crsinfosolutions.com/java-naming-conventions/#:~:text=camelCase%20(Lower%20Camel%20Case),subsequent%20starting%20word%20is%20capitalized. |website=www.crsinfosolutions.com |access-date=2024-06-29}}</ref>。ただし、いずれもユーザー定義型の名前は大文字で始めるアッパーキャメルケースである。


[[ファイルシステム]]において、[[ファイル (コンピュータ)|ファイル]]や[[ディレクトリ]](フォルダー)の命名にキャメルケースが使われることも多い<ref>{{Cite web |title=Naming files, folders and other things — The Turing Way |url=https://book.the-turing-way.org/project-design/filenaming.html |website=book.the-turing-way.org |access-date=2024-06-29}}</ref><ref>{{Cite web |title=<nowiki>File Naming Conventions | Data Management</nowiki> |url=https://datamanagement.hms.harvard.edu/plan-design/file-naming-conventions |website=datamanagement.hms.harvard.edu |access-date=2024-06-29 |language=en}}</ref>。特に[[コマンドラインインタプリタ|コマンドラインシェル]]でファイルシステムを操作するとき、スペースが含まれている名前は問題を引き起こすことが多いため<ref>{{Cite web |title=How to Deal With Spaces in Filenames on Linux |url=https://www.howtogeek.com/850124/spaces-in-filenames-on-linux/ |website=How-To Geek |date=2022-12-14 |access-date=2024-06-29 |language=en |first=Dave |last=McKay}}</ref><ref>{{Cite web |title=Dealing with spaces in file names in a shell script |url=https://www.unix.com/shell-programming-and-scripting/76795-dealing-spaces-file-names-shell-script.html |website=www.unix.com |access-date=2024-06-29 |language=en}}</ref>、文字数の増大を抑制しつつ可読性を確保できるキャメルケースはこの点で有利である。ただし、[[オペレーティングシステム]]やファイルシステムなどの環境によっては、大文字・小文字が同一視されたり、全て大文字として扱われて区別できなかったりする場合もある<ref>{{Cite web |title=Case Sensitivity |url=https://learn.microsoft.com/en-us/windows/wsl/case-sensitivity |website=learn.microsoft.com |date=2022-04-27 |access-date=2024-06-29 |language=en-us |last=craigloewen-msft}}</ref><ref>{{Cite web |title=Case-sensitivity |url=https://help.hcltechsw.com/versionvault/2.0.1/oxy_ex-1/com.ibm.rational.clearcase.cc_admin.doc/topics/c_netadm_case.html |website=help.hcltechsw.com |access-date=2024-06-29 |language=en-us}}</ref>。
[[ファイルシステム]]において、[[ファイル (コンピュータ)|ファイル]]や[[ディレクトリ]](フォルダー)の命名にキャメルケースが使われることも多い<ref>{{Cite web |title=Naming files, folders and other things — The Turing Way |url=https://book.the-turing-way.org/project-design/filenaming.html |website=book.the-turing-way.org |access-date=2024-06-29}}</ref><ref>{{Cite web |title=<nowiki>File Naming Conventions | Data Management</nowiki> |url=https://datamanagement.hms.harvard.edu/plan-design/file-naming-conventions |website=datamanagement.hms.harvard.edu |access-date=2024-06-29 |language=en}}</ref>。特に[[コマンドラインインタプリタ|コマンドラインシェル]]でファイルシステムを操作する、スペースが含まれている名前は問題を引き起こすことが多いため<ref>{{Cite web |title=How to Deal With Spaces in Filenames on Linux |url=https://www.howtogeek.com/850124/spaces-in-filenames-on-linux/ |website=How-To Geek |date=2022-12-14 |access-date=2024-06-29 |language=en |first=Dave |last=McKay}}</ref><ref>{{Cite web |title=Dealing with spaces in file names in a shell script |url=https://www.unix.com/shell-programming-and-scripting/76795-dealing-spaces-file-names-shell-script.html |website=www.unix.com |access-date=2024-06-29 |language=en}}</ref>、文字数の増大を抑制しつつ可読性を確保できるキャメルケースはこの点で有利である。ただし、[[オペレーティングシステム]]やファイルシステムなどの環境によっては、大文字・小文字がされ、全て大文字として扱われて区別できな場合もある<ref>{{Cite web |title=Case Sensitivity |url=https://learn.microsoft.com/en-us/windows/wsl/case-sensitivity |website=learn.microsoft.com |date=2022-04-27 |access-date=2024-06-29 |language=en-us |=craigloewen-msft}}</ref><ref>{{Cite web |title=Case-sensitivity |url=https://help.hcltechsw.com/versionvault/2.0.1/oxy_ex-1/com.ibm.rational.clearcase.cc_admin.doc/topics/c_netadm_case.html |website=help.hcltechsw.com |access-date=2024-06-29 |language=en-us}}</ref>。


初期の[[ウィキ]]において、キャメルケースを用いた語を[[ハイパーリンク|リンク]]とするという方法が用いられていた<ref>{{Cite web |title=PURR - Wiki: Help: Wiki Page Names |url=https://purr.purdue.edu/wiki/Help:WikiPageNames |website=purr.purdue.edu |access-date=2024-06-29}}</ref><ref>{{Cite web |url=https://arxiv.org/pdf/0802.0745 |title=Wikis are good for knowlegde management |access-date=2024-6-29 |publisher=arxiv.org}}</ref>。現在では、例えば{{lang|en|[[MediaWiki]]}}が「<code><nowiki>[[</nowiki></code>」と「<code><nowiki>]]</nowiki></code>」を用いてリンクを表しているように、キャメルケースによるリンクを用いない方法が多く用いられている。
初期の[[ウィキ]]において、キャメルケースを用いた語を[[ハイパーリンク|リンク]]とするという方法が用いられていた<ref>{{Cite web |title=PURR - Wiki: Help: Wiki Page Names |url=https://purr.purdue.edu/wiki/Help:WikiPageNames |website=purr.purdue.edu |access-date=2024-06-29}}</ref><ref>{{Cite web |url=https://arxiv.org/pdf/0802.0745 |title=Wikis are good for knowlegde management |access-date=2024-6-29 |=arxiv.org}}</ref>。現在では、例えば{{lang|en|[[MediaWiki]]}}が「<code><nowiki>[[</nowiki></code>」と「<code><nowiki>]]</nowiki></code>」を用いてリンクを表しているように、キャメルケースによるリンクを用いない方法が多く用いられている。


{{要出典|範囲=元を正せば、キャメルケースは複合語から成る[[人名]]に多く使われてきた|date=2024年6月}}。{{読み仮名|{{lang|en|McDonald}}|マクドナルド}}{{efn|「{{lang|en|Mc}}」は[[ゲール語]]で「息子」を意味する語であり、{{lang|en|McDonald}} は「ドナルドの息子」という意味の複合語である。}}などは日本語話者にもなじみ深くなった名前のうちの一つである。日本語話者が日常生活の中で目にするキャメルケースには、商品名やサービス名が多い。[[PlayStation (ゲーム機)|PlayStation]]、[[iPhone]]、[[BlackBerry]]、[[Microsoft OneDrive|OneDrive]]や[[YouTube]]などがその例である。これらはスペースで単語を区切らず、連結された一つの語に見える固有名詞とすることによって、Web[[検索エンジン]]に区別されやすいという利点がある<ref>{{Cite web |title=<nowiki>SEO: What about spaces in URLs? | Combell</nowiki> |url=https://www.combell.com/en/blog/seo-what-about-spaces-in-urls/ |date=2015-09-18 |access-date=2024-06-29 |language=en-US}}</ref><ref>{{Cite web |title=Increasing your site’s visibility to search engines |url=https://support.squarespace.com/hc/en-us/articles/205814568-Increasing-your-site-s-visibility-to-search-engines |website=Squarespace Help Center |date=2023-07-10 |access-date=2024-06-29 |language=en-US}}</ref>。
{{要出典|範囲=元を正せば、キャメルケースは複合語から成る[[人名]]に多く使われてきた|date=2024年6月}}。{{読み仮名|{{lang|en|McDonald}}|マクドナルド}}{{efn|「{{lang|en|Mc}}」は[[ゲール語]]で「息子」を意味する語であり、{{lang|en|McDonald}} は「ドナルドの息子」という意味の複合語である。}}などは日本語話者にもみ深くなった名前のうちの一つである。日本語話者が日常生活の中で目にするキャメルケースには、商品名やサービス名が多い。[[PlayStation (ゲーム機)|PlayStation]]、[[iPhone]]、[[BlackBerry]]、[[Microsoft OneDrive|OneDrive]]や[[YouTube]]などがその例である。これらはスペースで単語を区切らず、連結された一つの語に見える固有名詞とすることによって、Web[[検索エンジン]]に区別されやすいという利点がある<ref>{{Cite web |title=<nowiki>SEO: What about spaces in URLs? | Combell</nowiki> |url=https://www.combell.com/en/blog/seo-what-about-spaces-in-urls/ |date=2015-09-18 |access-date=2024-06-29 |language=en-US}}</ref><ref>{{Cite web |title=Increasing your site’s visibility to search engines |url=https://support.squarespace.com/hc/en-us/articles/205814568-Increasing-your-site-s-visibility-to-search-engines |website=Squarespace Help Center |date=2023-07-10 |access-date=2024-06-29 |language=en-US}}</ref>。


== キャメルケースとスペルチェック ==
== キャメルケースとスペルチェック ==
{{要出典|範囲=キャメルケースの欠点として、綴りミスを自動検出するスペルチェッカーの利用が難しくなる|date=2024年6月}}、ということが挙げられる。[[Microsoft Word]]<ref>{{Cite web |url=https://www.microsoft.com/ja-jp/microsoft-365/word |title=Microsoft Word |access-date=2024-6-29 |publisher=Microsoft}}</ref>のような一般的な[[ワープロソフト|ワードプロセッサソフトウェア]]では、{{要出典|範囲=広く知られていて辞書データベースに登録されているような固有名詞を除き、キャメルケースの[[スペルチェック]]に対応しておらず|date=2024年6月}}、スペルミスであると判定してしまう。ただし、{{要出典|範囲=自然言語の文章中に登場するキャメルケース(特にローワーキャメルケース)は、一般的にスペースやハイフンの不足などによる誤りであることが多いため、この動作は妥当であるともえる|date=2024年6月}}。
{{要出典|範囲=キャメルケースの欠点として、綴りミスを自動検出するスペルチェッカーの利用が難しくなる|date=2024年6月}}、ということが挙げられる。[[Microsoft Word]]<ref>{{Cite web |url=https://www.microsoft.com/ja-jp/microsoft-365/word |title=Microsoft Word |access-date=2024-6-29 |=Microsoft}}</ref>のような一般的な[[ワープロソフト|ワードプロセッサソフトウェア]]では、{{要出典|範囲=広く知られていて辞書データベースに登録されているような固有名詞を除き、キャメルケースの[[スペルチェック]]に対応しておらず|date=2024年6月}}、スペルミスであると判定してしまう。ただし、{{要出典|範囲=自然言語の文章中に登場するキャメルケース(ローワーキャメルケース)は、一般的にスペースやハイフンの不足などによる誤りであることが多いため、この動作は妥当であるともえる|date=2024年6月}}。


プログラミング時に用いられるコードエディタは[[テキストエディタ|テキストエディター]]の一種だが、[[コメント (コンピュータ)|コメント]]内や[[文字列リテラル]]内の文章だけでなく、識別子のスペルチェックにも対応しており<ref>{{Cite web |title=スペル チェック機能の詳細 - Visual Studio (Windows) |url=https://learn.microsoft.com/ja-jp/visualstudio/ide/text-spell-checker?view=vs-2022 |website=learn.microsoft.com |date=2023-05-24 |access-date=2024-06-29 |language=ja-jp |last=anandmeg}}</ref><ref>{{Cite web |title=<nowiki>Spell Checker | CodeRush | DevExpress Documentation</nowiki> |url=https://docs.devexpress.com/CodeRushForRoslyn/117202/static-code-analysis/spell-checker |website=docs.devexpress.com |access-date=2024-06-29}}</ref>、また判定の容易なスネークケースやケバブケース(チェインケース)だけでなく、キャメルケースのスペルチェックにも対応しているものがある<ref>[https://learn.microsoft.com/en-us/visualstudio/ide/text-spell-checker Learn about the Spell Checker - Visual Studio (Windows) | Microsoft Learn]</ref><ref>{{Cite web |title=<nowiki>Spell Checking | IntelliJ Platform Plugin SDK</nowiki> |url=https://plugins.jetbrains.com/docs/intellij/spell-checking.html |website=IntelliJ Platform Plugin SDK Help |access-date=2024-06-29 |language=en-US}}</ref>。
プログラミング時に用いられるコードエディタは[[テキストエディタ]]の一種だが、[[コメント (コンピュータ)|コメント]]内や[[文字列リテラル]]内の文章だけでなく、識別子のスペルチェックにも対応しており<ref>{{Cite web |title=スペル チェック機能の詳細 - Visual Studio (Windows) |url=https://learn.microsoft.com/ja-jp/visualstudio/ide/text-spell-checker?view=vs-2022 |website=learn.microsoft.com |date=2023-05-24 |access-date=2024-06-29 |language=ja-jp |=anandmeg}}</ref><ref>{{Cite web |title=<nowiki>Spell Checker | CodeRush | DevExpress Documentation</nowiki> |url=https://docs.devexpress.com/CodeRushForRoslyn/117202/static-code-analysis/spell-checker |website=docs.devexpress.com |access-date=2024-06-29}}</ref>、また判定の容易なスネークケースやケバブケース(チェインケース)だけでなく、キャメルケースのスペルチェックにも対応しているものがある<ref>https://learn.microsoft.com/en-us/visualstudio/ide/text-spell-checker - | </ref><ref>{{Cite web |title=<nowiki>Spell Checking | IntelliJ Platform Plugin SDK</nowiki> |url=https://plugins.jetbrains.com/docs/intellij/spell-checking.html |website=IntelliJ Platform Plugin SDK Help |access-date=2024-06-29 |language=en-US}}</ref>。


== 命名規則一覧 ==
== 命名規則一覧 ==
65行目: 80行目:
|[[スクリーミングスネークケース]]
|[[スクリーミングスネークケース]]
|screaming snake case
|screaming snake case
|単語間をアンダースコア(<code>_</code>)で繋ぎ、全て大文字にする形式。「アッパースネークケース(upper snake case)」や「コンスタントケース(constant case)」とも呼ばれる<ref name="ewords_snake_case">[https://e-words.jp/w/%E3%82%B9%E3%83%8D%E3%83%BC%E3%82%AF%E3%82%B1%E3%83%BC%E3%82%B9.html スネークケース(アンダースコア記法)とは - 意味をわかりやすく - IT用語辞典 e-Words]</ref>。
|単語間をアンダースコア(<code>_</code>)で繋ぎ、全て大文字にする形式。「アッパースネークケース(upper snake case)」や「コンスタントケース(constant case)」とも呼ばれる<ref name="ewords_snake_case">https://e-words.jp/w/%E3%82%B9%E3%83%8D%E3%83%BC%E3%82%AF%E3%82%B1%E3%83%BC%E3%82%B9.html IT用語辞典 e-Words</ref>。
|<code>EXAMPLE_VARIABLE</code>
|<code>EXAMPLE_VARIABLE</code>
|-
|-

2024年7月13日 (土) 21:17時点における版

ラクダ(camel)のこぶに見えることから名付けられた
キャメルケースの例(シンガポールのマクドナルド店舗)

キャメルケース: camel case)は、英語複合語フレーズをひと綴りとして、各単語頭文字大文字で表現する命名規則である[1][2]。キャメルケースという命名は、全体を俯瞰すると大文字の部分が「ラクダのこぶ」のように見えることに由来する[3][4][5]。例えば、「camel case」をキャメルケースで表現すると、「camelCase」または「CamelCase」となる。通常「キャメルケース」と呼ぶ場合は前者を指すが[注釈 1]、両者を厳密に区別するために前者を「ローワーキャメルケース[注釈 2]」、後者を「アッパーキャメルケース」と呼ぶ。

キャメルケースという語はプログラミングの文脈で最も一般的に使用されている[1]が、この語は他の分野においても広く用いられている。例えば、デジタルメディアマーケティングにおいては、ウェブサイトURLドメイン名可読性を向上させるためにキャメルケースが使用されることがある[16][17]。また、ドキュメントやガイドラインにおいては、セクション名や章タイトルの視認性を高める目的で採用されることもある[18][19]。さらに、ブランド名製品名においても、一貫性を保ちつつ視覚的に目立つ名前を作成するためにキャメルケースが用いられることがある[20][21]。このように、キャメルケースはその利便性から広範な応用がなされており、多岐に渡る分野でその有用性が認識されている。

歴史

1970年代:キャメルケースのスタイルの誕生

キャメルケースのスタイルの起源は1970年代に遡る[22][23]。この時期、プログラミング言語の発展に伴い、メソッド名や変数名の命名規則が重要視され始めた。特に、長い名前を一つの識別子として扱うために、単語境界を視覚的に表現する方法として各単語の頭文字を大文字にするキャメルケースのスタイルが考案された(この時点では「キャメルケース」という用語は存在していない)。

1980年代:Pascalと「mixed-case」

1980年代には、PascalC言語などのプログラミング言語が普及し、キャメルケースのスタイルが広く用いられるようになった[24][25][26][27]。特にPascalでは、メソッド名や変数名にキャメルケースのスタイルが推奨されていた。これは、コードの読みやすさと一貫性を向上させるためであり、特にPascalの教育的な側面が強調される中で、この命名規則が採用された。この時期、キャメルケースのスタイルは"mixed case"と呼ばれていた[28][注釈 3]

1990年代:Javaの普及

1990年代には、Javaの登場により、キャメルケースのスタイルがさらに普及した[29][30]。Javaでは、クラス名にアッパーキャメルケース、変数名やメソッド名にローワーキャメルケースが推奨されていた。この時期に、キャメルケースのスタイルが広く認知されるようになった。

2000年代:.NET Frameworkの標準化

2000年代には、Microsoft.NET Frameworkをリリースし、その中でキャメルケースの使用が標準化された。この時に、「キャメルケース」という用語が考案された。.NET Frameworkの開発において重要な役割を果たしたMicrosoftの元エンジニアプログラムマネージャーのブラッド・エイブラムスは、著書『Framework Design Guidelines: Conventions, Idioms, and Patterns for Reusable .NET Libraries[31]』の中で、.NET Frameworkの初期設計の際、名付けスタイルの議論を円滑に進めるための用語を作成したと述べている。この時、各単語の頭文字を大文字にするスタイルは「PascalCasing」と命名され、先頭の語のみ頭文字を小文字にするスタイルは「camelCasing」と命名された[32]。「PascalCasing」という命名に関しては、Turbo Pascal設計者であり、.NET設計チームの主要なメンバーでもあったアンダース・ヘルスバーグが、これはプログラミング言語Pascalによって普及したスタイルであるとして「PascalCasing」という用語を提案した[33][34]。これらの用語の選定にあたって、特に異論は出なかったとされる[31][35]。「PascalCasing」はパスカルケース: Pascal case[注釈 4])と表記されることもある。また、同じ.NETの系譜であるC#でもキャメルケースが公式に推奨される命名規則となった。これによって、キャメルケースはプログラミングにおける標準的な命名規則の一つとして確立された。

2010年代以降:モダン言語での普及

2010年代以降、キャメルケースは多くのプログラミング言語やフレームワークで一般的な命名規則として使われ続けている[36][37]。特に、JavaScriptPythonなどのモダンな言語でもキャメルケースが広く採用されている。ただし、これらは厳密には.NETの文脈に属さないため、同じスタイルでも「ローワーキャメルケース」と呼ぶ[38][39]

文脈別の使い分け

.NETのガイドライン[40][注釈 5]では、先頭の語も含めて各構成語の頭文字を大文字にするスタイルをパスカルケース、先頭の語のみ頭文字を小文字にするスタイルをキャメルケースとしており、プログラミングの文脈でキャメルケースと言えば後者のスタイルを指すことが多いが、場合によってはどちらもキャメルケースと呼ばれることがある[注釈 6]。これらを厳密に区別するために、「アッパーキャメルケース」や「ローワーキャメルケース」といった用語が使われる[44][45]。厳密には「パスカルケース」および「キャメルケース」は.NETの文脈で使われるものであるため、他のプログラミング言語も含め、より広範な文脈では「アッパーキャメルケース」「ローワーキャメルケース」を使う[23]。それぞれの特徴については「アッパーキャメルケース」「ローワーキャメルケース」を参照されたい。

名称 表記例 備考
アッパーキャメルケース: upper camel case: UCC)、またはパスカルケース GetInputReader 複合語の先頭を、大文字で書き始める。
ローワーキャメルケース: lower camel case: LCC)、または単にキャメルケース getInputReader 複合語の先頭を、小文字で書き始める。

なお、英語で大文字はupper case、小文字はlower caseであるが、これらは活版印刷の名残である[46][47]

.NET FrameworkのSystem.Xml.Serialization.CodeIdentifierクラスには、XMLの要素や属性の名前から取得されたメソッド引数などのようなコードの実体から、パスカルケース(アッパーキャメルケース)の文字列を生成するメソッドMakePascal()[48]と、キャメルケース(ローワーキャメルケース)の文字列を生成するメソッドMakeCamel()[49]が当初から用意されていた。

利点

利点については、「ローワーキャメルケース」「アッパーキャメルケース」の「利点」項目で説明されている。

キャメルケースについて、利点という点で上記の利点と比較して特筆すべき点はないため、このページでは省略する。

欠点

欠点については、「ローワーキャメルケース」「アッパーキャメルケース」の「欠点」項目で説明されている。

キャメルケースについて、欠点という点で上記の欠点と比較して特筆すべき点はないため、このページでは省略する。

適用例

以下について以外は「ローワーキャメルケース」「アッパーキャメルケース」の「適用例」項目で説明されている。

CamelCase

Visual BasicWindows APIOLE/COMの影響を[50][51]、また.NET Frameworkや.NET言語(C#、VB.NETなど)はDelphiObject Pascal)の影響を受けており[52][53]、メソッドの名前を大文字で始めるアッパーキャメルケースとなっているが[32][54]Javaはメソッドの名前を小文字で始めるローワーキャメルケースとなっている[55]。ただし、いずれもユーザー定義型の名前は大文字で始めるアッパーキャメルケースである。

ファイルシステムにおいて、ファイルディレクトリ(フォルダー)の命名にキャメルケースが使われることも多い[56][57]。特にコマンドラインシェルでファイルシステムを操作する際、スペースが含まれている名前は問題を引き起こすことが多いため[58][59]、文字数の増大を抑制しつつ可読性を確保することのできるキャメルケースはこの点で有利である。ただし、オペレーティングシステムやファイルシステムなどの環境によっては、大文字・小文字が区別されない、または全て大文字として扱われて区別できない、という場合もある[60][61]

初期のウィキにおいて、キャメルケースを用いた語をリンクとするという方法が用いられていた[62][63]。現在では、例えばMediaWikiが「[[」と「]]」を用いてリンクを表しているように、キャメルケースによるリンクを用いない方法が多く用いられている。

元を正せば、キャメルケースは複合語から成る人名に多く使われてきた[要出典]McDonaldマクドナルド[注釈 7]などは日本語話者にも馴染み深くなった名前のうちの一つである。日本語話者が日常生活の中で目にするキャメルケースには、商品名やサービス名が多い。PlayStation[64]iPhone[65]BlackBerry[66]OneDrive[67]YouTube[68]などがその例である。これらはスペースで単語を区切らず、連結された一つの語に見える固有名詞とすることによって、Web検索エンジンに区別されやすいという利点がある[69][70]

キャメルケースとスペルチェック

キャメルケースの欠点として、綴りミスを自動検出するスペルチェッカーの利用が難しくなる[要出典]、ということが挙げられる。Microsoft Word[71]のような一般的なワードプロセッサソフトウェアでは、広く知られていて辞書データベースに登録されているような固有名詞を除き、キャメルケースのスペルチェックに対応しておらず[要出典]、スペルミスであると判定してしまう。ただし、自然言語の文章中に登場するキャメルケース(ローワーキャメルケース)は、一般的にスペースやハイフン-の不足などによる誤りであることが多いため、この動作は妥当であるともいえる[要出典]

プログラミング時に用いられるコードエディタはテキストエディタの一種だが、コメント内や文字列リテラル内の文章だけでなく、識別子のスペルチェックにも対応しており[72][73]、また判定の容易なスネークケースやケバブケース(チェインケース / チェーンケース)だけでなく、キャメルケースのスペルチェックにも対応しているものがある[74][75]

命名規則一覧

名称 英語表記 説明 表記例
スネークケース snake case 単語間をアンダースコア(_)で繋ぐ形式。 example_variable
スクリーミングスネークケース screaming snake case 単語間をアンダースコア(_)で繋ぎ、全て大文字にする形式。「アッパースネークケース(upper snake case)」や「コンスタントケース(constant case)」とも呼ばれる[76] EXAMPLE_VARIABLE
キャメルケース camel case 各単語の頭文字を大文字にし、単語を連結する形式(最初の単語のみ頭文字が小文字)。.NETの文脈で使用。 exampleVariable
ローワーキャメルケース lower camel case キャメルケースと同じ形式だが、フレームワークや言語に依存しない表現。 exampleVariable
パスカルケース Pascal case 各単語の頭文字を大文字にし、単語を連結する形式(キャメルケースと似ているが、最初の単語の頭文字も大文字)。.NETの文脈で使用。 ExampleVariable
アッパーキャメルケース upper camel case パスカルケースと同じ形式だが、フレームワークや言語に依存しない表現。 ExampleVariable
ケバブケース kebab case 単語間をハイフン(-)で繋ぎ、各単語の頭文字を小文字にする形式。「チェインケース / チェーンケース(chain case)」とも呼ばれる[76] example-variable
トレインケース train case 単語間をハイフン(-)で繋ぎ、各単語の頭文字を大文字にする形式。 Example-Variable
ドットケース dot case 単語間をドット(.)で繋ぐ形式。 example.variable

脚注

注釈

  1. ^ 各辞書で「"通常"、キャメルケースと呼ぶ場合ローワーキャメルケースを指す」のように表現されていることから、場合によってはパスカルケース(アッパーキャメルケース)を指すこともある(「総称としての紹介[6]」、「"通常"という表現を用いた紹介[7][8]」が存在する)。
  2. ^ 「ローワー」という読み仮名表記は、「大辞林第四版[9]」「大辞泉[10]」「日本語シソーラス第2版[11]」「コトバンク[12]」「IT用語辞典[13]」「goo辞書[14]」「シマウマ用語集[15]」など、様々な辞書で採用されている表記である。
  3. ^ このJavaのドキュメントはSunによって1999年に書かれた版であり、.NETが登場する前から「mixed case」という用語が使われていたことを意味している。
  4. ^ 「Pascal」は固有名詞であるため、先頭を小文字にしてはならない。
  5. ^ このガイドラインページは『Framework Design Guidelines: Conventions, Idioms, and Patterns for Reusable .NET Libraries, 2nd Edition』からの抜粋であるが、Krzysztof CwalinaとBrad abramsはウェブページの直接の著者ではない。
  6. ^ 各辞書で「"通常"、キャメルケースと呼ぶ場合ローワーキャメルケースを指す」のように表現されていることから、場合によってはパスカルケース(アッパーキャメルケース)を指すこともある(「総称としての紹介[41]」、「"通常"という表現を用いた紹介[42][43]」が存在する)。
  7. ^ Mc」はゲール語で「息子」を意味する語であり、McDonald は「ドナルドの息子」という意味の複合語である。

出典

  1. ^ a b キャメルケースとは - IT用語辞典”. IT用語辞典 e-Words. 2024年6月29日閲覧。
  2. ^ camel case”. Cambridge Dictionary. 2024年6月29日閲覧。
  3. ^ Camel case - MDN Web Docs Glossary: Definitions of Web-related terms | MDN” (英語). developer.mozilla.org (2024年5月7日). 2024年6月29日閲覧。
  4. ^ camel case - Binnenmajuskel - New entry for LEO: English ⇔ German Forums - leo.org”. dict.leo.org. 2024年6月29日閲覧。
  5. ^ What Is Camel Case? Meaning and Examples Explained” (英語). www.98thpercentile.com. 2024年6月29日閲覧。
  6. ^ camel caseの意味・使い方・読み方 | Weblio英和辞書”. ejje.weblio.jp. 2024年7月2日閲覧。
  7. ^ キャメルケース(camel case)とは? 意味・読み方・使い方をわかりやすく解説 - goo国語辞書”. goo辞書. 2024年7月2日閲覧。
  8. ^ キャメルケースとは? 意味や使い方”. コトバンク. 2024年7月2日閲覧。
  9. ^ 大辞林第四版”. 三省堂. 2024年7月1日閲覧。
  10. ^ 大辞泉”. 大辞泉. 2024年7月1日閲覧。
  11. ^ 日本語シソーラス 第2版 類語検索辞典”. 大修館書店. 2024年7月1日閲覧。
  12. ^ ローワーキャメルケース”. コトバンク. 2024年7月1日閲覧。
  13. ^ キャメルケース”. IT用語辞典. 2024年7月1日閲覧。
  14. ^ ローワーキャメルケース”. goo辞書. 2024年7月1日閲覧。
  15. ^ キャメルケース”. シマウマ用語集. 2024年7月1日閲覧。
  16. ^ Sams, Chris (2024年2月21日). “What Influence Will Capitalization In URLs Have On SEO In 2024?” (英語). JEMSU. 2024年6月29日閲覧。
  17. ^ Editorial style update: Capital letters in websites, email addresses and hashtags” (英語). Brand Updates (2019年8月5日). 2024年6月29日閲覧。
  18. ^ Guideline In Document Name Publication Section Is Written In Camelcase”. Nexedi. 2024年6月29日閲覧。
  19. ^ Pandoc User’s Guide 日本語版 — 日本Pandocユーザ会”. pandoc-doc-ja.readthedocs.io. 2024年6月29日閲覧。
  20. ^ Camel Case Vs Pascal Case Vs Snake Case: What's The Difference And Why Is It Important? - Dataconomy” (英語). Dataconomy (2023年11月3日). 2024年6月29日閲覧。
  21. ^ The Art of Naming”. Zinzin. 2024年6月29日閲覧。
  22. ^ Knuth, Donald Ervin (1997) (英語). The Art of Computer Programming. Addison-Wesley. ISBN 978-0-201-03809-5. https://www.google.co.jp/books/edition/The_Art_of_Computer_Programming/3YpQAAAAMAAJ?hl=ja&gbpv=1&bsq=The+Art+of+Computer+Programming&dq=The+Art+of+Computer+Programming&printsec=frontcover 
  23. ^ a b McConnell, Steve (1993) (英語). Code Complete: A Practical Handbook of Software Construction. Microsoft Press. ISBN 978-1-55615-484-3. https://www.google.co.jp/books/edition/Code_Complete/lohA2aY9gu0C?hl=ja&gbpv=1&bsq=Code+Complete:+A+Practical+Handbook+of+Software+Construction&dq=Code+Complete:+A+Practical+Handbook+of+Software+Construction&printsec=frontcover 
  24. ^ Jensen, Kathleen; Wirth, Niklaus (1985) (英語). Pascal User Manual and Report. Springer-Verlag. ISBN 978-0-387-96048-7. https://www.google.co.jp/books/edition/Pascal_User_Manual_and_Report/wCmzAAAAIAAJ?hl=ja&gbpv=1&bsq=Pascal+User+Manual+and+Report&dq=Pascal+User+Manual+and+Report&printsec=frontcover 
  25. ^ Cooper, Doug (1993) (英語). Oh! Pascal!. W.W. Norton. ISBN 978-0-393-96399-1. https://www.google.co.jp/books/edition/Oh_Pascal/tmV5QgAACAAJ?hl=ja 
  26. ^ Kernighan, Brian W.; Ritchie, Dennis (1988-03-22) (英語). C Programming Language. Prentice Hall. ISBN 978-0-13-308621-8. https://www.google.co.jp/books/edition/C_Programming_Language/Yi5FI5QcdmYC?hl=ja&gbpv=1&bsq=The+C+Programming+Language&dq=The+C+Programming+Language&printsec=frontcover 
  27. ^ Pressman, Roger S. (2005) (英語). Software Engineering: A Practitioner's Approach. Palgrave Macmillan. ISBN 978-0-07-301933-8. https://www.google.co.jp/books/edition/Software_Engineering/bL7QZHtWvaUC?hl=ja&gbpv=1&dq=Software+Engineering:+A+Practitioner's+Approach&printsec=frontcover 
  28. ^ Naming Conventions”. ORACLE. 2024年7月14日閲覧。
  29. ^ Arnold, Ken; Gosling, James (1998) (英語). The Java Programming Language. Addison-Wesley. ISBN 978-0-201-31006-1. https://www.google.co.jp/books/edition/The_Java_Programming_Language/M6tQAAAAMAAJ?hl=ja&gbpv=1&bsq=The+Java+Programming+Language&dq=The+Java+Programming+Language&printsec=frontcover 
  30. ^ Bloch, Joshua (2008-05-08) (英語). Effective Java. Addison-Wesley Professional. ISBN 978-0-13-277804-6. https://www.google.co.jp/books/edition/Effective_Java/ka2VUBqHiWkC?hl=ja&gbpv=1&dq=Effective+Java&printsec=frontcover 
  31. ^ a b Krzysztof Cwalina; Brad Abrams (2008-10-22). Framework Design Guidelines: Conventions, Idioms, and Patterns for Reusable .NET Libraries (Second ed.). Addison-Wesley Professional. p. 38. ISBN 978-0321545619 
  32. ^ a b KrzysztofCwalina: “Capitalization Conventions - Framework Design Guidelines” (英語). learn.microsoft.com (2023年10月3日). 2024年7月13日閲覧。
  33. ^ The Private Life of a Public API”. www.moserware.com. 2024年6月29日閲覧。
  34. ^ MICROSOFT ® .NET DEVELOPER”. Pearson Education. 2024年6月29日閲覧。
  35. ^ クリストフ・ツヴァリナ、ブラッド・エイブラムス『.NETのクラスライブラリ設計』日経BP、2009年12月28日、32頁。ISBN 978-4-89100-676-1 
  36. ^ Crockford, Douglas (2008-05-08) (英語). JavaScript: The Good Parts: The Good Parts. "O'Reilly Media, Inc.". ISBN 978-0-596-55487-3. https://www.google.co.jp/books/edition/JavaScript_The_Good_Parts/PXa2bby0oQ0C?hl=ja&gbpv=1&printsec=frontcover 
  37. ^ Matthes, Eric (2015-11-20) (英語). Python Crash Course: A Hands-On, Project-Based Introduction to Programming. No Starch Press. ISBN 978-1-59327-603-4. https://www.google.co.jp/books/edition/Python_Crash_Course/RXoZCwAAQBAJ?hl=ja&gbpv=1&dq=Python+Crash+Course&printsec=frontcover 
  38. ^ キャメルケースとは - IT用語辞典”. IT用語辞典 e-Words. 2024年7月1日閲覧。
  39. ^ ローワーキャメルケースとは? 意味や使い方”. コトバンク. 2024年7月1日閲覧。
  40. ^ フレームワーク デザインのガイドライン”. learn.microsoft.com (2024年1月27日). 2024年6月29日閲覧。
  41. ^ camel caseの意味・使い方・読み方 | Weblio英和辞書”. ejje.weblio.jp. 2024年7月2日閲覧。
  42. ^ キャメルケース(camel case)とは? 意味・読み方・使い方をわかりやすく解説 - goo国語辞書”. goo辞書. 2024年7月2日閲覧。
  43. ^ キャメルケースとは? 意味や使い方”. コトバンク. 2024年7月2日閲覧。
  44. ^ A Simple Approach to Optimized Text Compression's Performance”. IEEE Xplore. 2024年6月29日閲覧。
  45. ^ Universal Utility Data Exchange (UUDEX) – Information Exchange Structures – Rev 1”. アメリカ合衆国エネルギー省. 2024年6月29日閲覧。
  46. ^ Griffin, Dori (2021-12-30) (英語). Type Specimens: A Visual History of Typesetting and Printing. Bloomsbury Publishing. ISBN 978-1-350-11661-0. https://books.google.co.jp/books?hl=ja&lr=lang_ja%7Clang_en&id=-rdREAAAQBAJ&oi=fnd&pg=PP1&dq=%22upper+case%22+%22lower+case%22+origin+%22typesetting%22+%22history%22&ots=yogW2WIhm7&sig=yil1DC2NcXyz_i6YHh2tx_UWlhc#v=onepage&q=%22upper%20case%22%20%22lower%20case%22%20origin%20%22typesetting%22%20%22history%22&f=false 
  47. ^ Wyatt, Christopher Scott; DeVoss, Dànielle Nicole (2017-09-01) (英語). Type Matters: The Rhetoricity of Letterforms. Parlor Press LLC. ISBN 978-1-60235-978-9. https://books.google.co.jp/books?hl=ja&lr=lang_ja%7Clang_en&id=EKwWEAAAQBAJ&oi=fnd&pg=PA3&dq=%22upper+case%22+%22lower+case%22+origin+%22typesetting%22+%22history%22&ots=bfzTiv_Bfp&sig=u7xhGw9f_EzJFZFIexhnETHdExY#v=onepage&q=upper%20case&f=false 
  48. ^ dotnet-bot: “CodeIdentifier.MakePascal(String) Method (System.Xml.Serialization)” (英語). learn.microsoft.com. 2024年7月7日閲覧。
  49. ^ dotnet-bot: “CodeIdentifier.MakeCamel(String) Method (System.Xml.Serialization)” (英語). learn.microsoft.com. 2024年7月7日閲覧。
  50. ^ Petzold, Charles (2013-01-15) (英語). Programming Windows. Pearson Education. ISBN 978-0-7356-7172-0. https://www.google.co.jp/books/edition/Programming_Windows/Da9CAwAAQBAJ?hl=ja&gbpv=0 
  51. ^ Dale Rogerson (1998-1-21). INSIDE COM (Microsoft Programming Series). 日経BP. https://www.amazon.co.jp/INSIDE-Microsoft-Programming-Dale-Rogerson/dp/1572313498 
  52. ^ Hejlsberg, Anders; Torgersen, Mads; Wiltamuth, Scott; Golde, Peter (2008-10-08) (英語). The C# Programming Language. Pearson Education. ISBN 978-0-321-59225-5. https://www.google.co.jp/books/edition/The_C_Programming_Language/ICe7ea4RscUC?hl=ja&gbpv=0 
  53. ^ Watkins, Damien; Hammond, Mark J.; Abrams, Brad (2003) (英語). Programming in the .NET Environment. Addison-Wesley Professional. ISBN 978-0-201-77018-6. https://www.google.co.jp/books/edition/Programming_in_the_NET_Environment/sWhAOMIf4MUC?hl=ja&gbpv=0 
  54. ^ Method Naming · Programming Basics with C# - Free Coding Book with Video Lessons”. csharp-book.softuni.org. 2024年6月29日閲覧。
  55. ^ Java Naming Conventions: PascalCase, camelCase, and more - CRS Info Solutions”. www.crsinfosolutions.com. 2024年6月29日閲覧。
  56. ^ Naming files, folders and other things — The Turing Way”. book.the-turing-way.org. 2024年6月29日閲覧。
  57. ^ File Naming Conventions | Data Management” (英語). datamanagement.hms.harvard.edu. 2024年6月29日閲覧。
  58. ^ McKay, Dave (2022年12月14日). “How to Deal With Spaces in Filenames on Linux” (英語). How-To Geek. 2024年6月29日閲覧。
  59. ^ Dealing with spaces in file names in a shell script” (英語). www.unix.com. 2024年6月29日閲覧。
  60. ^ craigloewen-msft: “Case Sensitivity” (英語). learn.microsoft.com (2022年4月27日). 2024年6月29日閲覧。
  61. ^ Case-sensitivity” (英語). help.hcltechsw.com. 2024年6月29日閲覧。
  62. ^ PURR - Wiki: Help: Wiki Page Names”. purr.purdue.edu. 2024年6月29日閲覧。
  63. ^ Wikis are good for knowlegde management”. arxiv.org. 2024年6月29日閲覧。
  64. ^ PlayStation 公式サイト | 本体・ゲームタイトル・周辺機器”. www.playstation.com. 2024年7月13日閲覧。
  65. ^ iPhone”. Apple(日本). 2024年7月13日閲覧。
  66. ^ BlackBerry - Company”. www.blackberry.com. 2024年7月13日閲覧。
  67. ^ 大切なものを OneDrive で安全に保存して共有しましょう”. Microsoft. 2024年7月14日閲覧。
  68. ^ YouTube”. www.youtube.com. 2024年7月13日閲覧。
  69. ^ SEO: What about spaces in URLs? | Combell” (英語). Combell (2015年9月18日). 2024年6月29日閲覧。
  70. ^ Increasing your site’s visibility to search engines” (英語). Squarespace Help Center (2023年7月10日). 2024年6月29日閲覧。
  71. ^ Microsoft Word”. Microsoft. 2024年6月29日閲覧。
  72. ^ anandmeg: “スペル チェック機能の詳細 - Visual Studio (Windows)”. learn.microsoft.com (2023年5月24日). 2024年6月29日閲覧。
  73. ^ Spell Checker | CodeRush | DevExpress Documentation”. docs.devexpress.com. 2024年6月29日閲覧。
  74. ^ anandmeg: “Learn about the Spell Checker - Visual Studio (Windows)” (英語). learn.microsoft.com (2023年5月24日). 2024年7月13日閲覧。
  75. ^ Spell Checking | IntelliJ Platform Plugin SDK” (英語). IntelliJ Platform Plugin SDK Help. 2024年6月29日閲覧。
  76. ^ a b スネークケースとは - IT用語辞典”. IT用語辞典 e-Words. 2024年7月13日閲覧。

関連項目