- Don't add code cruft. Avoid parentheses around conditions in if-statements or with the
returnkeyword. Don't add semicolons except where syntactically demanded in statements or to separate statements on the same line.
- Don't use ALL_CAPS; use camelCase
- Don't fight type inference. Use enumeration prefixes, self-references, and class names (with constructors) only when necessary or to clarify coding intent.
- Don't use
letis appropriate, especially for properties. The compiler better optimizes
letstatements for items whose values will not change during their lifetime. For example, Apple writes, "It is good practice to create immutable collections in all cases where the collection does not need to change. Doing so enables the Swift compiler to optimize the performance of the collections you create."
- Don't use classes when structs will do. Use class