0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

英語の変数名の付け方

Posted at

わかりやすい英語の変数名を付けるのに迷うのが嫌なので、一般法則的なものをまとめておく。

1.関数の命名
Principle01.動詞+目的語
Example01.getUserName(), setPlayerScore(), updateEnemyPos(), calculateDamage(), createEnemy(), deleteEnemy(), removeObject(), resetTimer(), loadNextScene(), sendRequest(), ProcessThrusting(),,,
Principle02.is/has/can + * (true or falseを返す場合)
Example02.isGameOver(), hasPermission(), canAttack(),,,
Principle03.on + * (なにかが発生したときに実行される場合)
Example03.onClick(), onPlayerDeath(), onCollisionEnter(), onKeyPress(),,,
2.クラスの命名
Principle01.基本は名詞を使う
Example01.Player, Enemy, GameManager,,,
Principle02.* + Manager/Contoller (管理系のクラスの場合)
Example02.GameManager, AudioManager, SceneController,,,
Principle03.* + Helper/Utils (Utilityクラスの場合)
Example03.MathHelper, StringUtils,,,
3.変数の命名
Principle01.数字は単語の後ろ
Example01.player1, player2, retryCount,,,
Principle02.序数は最初
Example02.firstPlayer, secondAttempt,,,
Principle03.* + count/limit (回数や制限を表す場合)
Example03.retryCount, speedLimit,,,
Reference03.numも良く使われるが、countの方が自然なこと多い。

0
0
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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?