Tutorial by Examples

Avoid Ambiguity The name of classes, structures, functions and variables should avoid ambiguity. Example: extension List { public mutating func remove(at position: Index) -> Element { // implementation } } The function call to this function will then look like this: li...
Using natural language Functions calls should be close to natural English language. Example: list.insert(element, at: index) instead of list.insert(element, position: index) Naming Factory Methods Factory methods should begin with the prefix `make`. Example: factory.makeObject() ...
Types & Protocols Type and protocol names should start with an uppercase letter. Example: protocol Collection {} struct String {} class UIView {} struct Int {} enum Color {} Everything else... Variables, constants, functions and enumeration cases should start with a lowercase letter. Exa...

Page 1 of 1