1
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 3 years have passed since last update.

命名規則

Posted at

単語の区切り方

Swiftではキャメルケースを使用します。

変数、定数: ローワーキャメルケースを使用。(camelCase, someVariable, someContentsのように最初の単語の頭が小文字で、それ以降の単語は頭文字を大文字にする)
型: キャメルケースを使用。(CamelCase, SomeVariable, SomeContentsのように最初の単語の頭文字から単語ごとに頭文字を大文字にする)

単語の選び方

・必要な単語は全て含める
悪い例: findUser(_:)関数は、どのようにユーザーを検索するのか曖昧
良い例: findUser(byID:)関数は、ユーザーIDで検索することがわかりやすい

・一般的でない単語の使用は避ける
悪い例:epidermisは「表皮」という意味だが、あまり一般的な単語ではない
良い例:skinは一般的かつ、epidermisと同様の意味の単語なので良い

・略語を避ける
悪い例:stmtはstatementの略語だがわかりにくい
良い例:statementのように単語は略さずそのまま使用する

まとめ

気にしなくても一応プログラムは動きますが、現場で開発する際は基本ルールに合わせて開発した方が他の人が見てもわかりやすいです。
また、キャメルケースかスネークケースかは、言語によって違うので、自分の使用する言語がどちらなのかを知っておく必要がありそうです。

参考

[増補改訂第3版]Swift実践入門 ── 直感的な文法と安全性を兼ね備えた言語 (WEB+DB PRESS plusシリーズ)

1
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
1
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?