0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【C】関数名変数名は自由につけて良いのか

Last updated at Posted at 2022-11-21

はじめに

関数、変数、型、オブジェクトなど、用語がかなりあるが、何が関数で何が変数か分からなくなる時が未だにちらほら。
CやC#、Unityで元から用意されているものは、用意されているまま使用しなければならない。
自分で作成する変数や関数の名前はどうつければ良いのか。
文字の大小が違うだけでエラーになったり。頭の中が散らかってきたので整理します。

関数、変数はある程度自由な名前でよし

シンプルで分かりやすい名前が好ましい。

変数名
【名詞】が基本
 頭もじは小文字で始まり、その後の頭もじは大文字。
 例) playScript、mainCamera、playerPos
 
関数名
【動詞】+【目的語】
(英語の文法になるから 【目的語】 +【動詞】)
単語の頭文字は大文字。
例)Start、Update、PlayBall、

命名規則

キャメルケース
  ・ローワーキャメルケース
    続く単語を大文字にする
  ・ アッパーキャメルケース
     単語の先頭を大文字にする

・スネークケース
  単語の間をアンダーバー、アンダースコア(_)でつなぐ
変数や関数に多い

・チェインケース
    単語間をハイフン(-)でつなぐ
    ドメイン、URL,ファイル名に多い

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?