Skip to content

Variables Capitalization

Pablo Villar edited this page Mar 20, 2017 · 4 revisions

Variables and constants names must be written using:

  • lowerCamelCase for variables (i.e. var)
  • lowerCamelCase for non-static constants (i.e. let)
  • PascalCase for static constants (i.e. static let)

Always be aware of acronyms.


Example

Good

let users: [User]
var selectedUser: User?
static let MaxNumberOfUsersAllowed = 100

Bad

let Users: [User] // NO
var SelectedUser: User? // NO
static let maxNumberOfUsersAllowed // NO!
static let MAX_NUMBER_OF_USERS_ALLOWED // NOOOOOO!!!!!!

Motivation
  • Consistency.
  • Readability: Variables or non-static constants are easier to be distinguished from static constants.