-
Notifications
You must be signed in to change notification settings - Fork 2
Variables Capitalization
Pablo Villar edited this page Mar 20, 2017
·
4 revisions
Variables and constants names must be written using:
-
lowerCamelCasefor variables (i.e.var) -
lowerCamelCasefor non-static constants (i.e.let) -
PascalCasefor static constants (i.e.static let)
Always be aware of acronyms.
Good
let users: [User]
var selectedUser: User?
static let MaxNumberOfUsersAllowed = 100Bad
let Users: [User] // NO
var SelectedUser: User? // NO
static let maxNumberOfUsersAllowed // NO!
static let MAX_NUMBER_OF_USERS_ALLOWED // NOOOOOO!!!!!!- Consistency.
- Readability: Variables or non-static constants are easier to be distinguished from static constants.