Swift Linguistics – The Correct Way Of Descriptive Naming

Swift Linguistics

Knowing the Swift linguistics can make naming accessible. Because of that coming up with simple or creative names will help your future self or other developers working on your code. And that is the real challenge.

For all the new developers out there, I recommend knowing the Swift language characteristics. That way coming up with simple and descriptive names won’t be a daunting task.

Recommended for you SWIFT – Access iOS Camera and Photo Library

Classes (class)

Classes are usually nouns. Apple recommends prefixing our classes with three or more letters to avoid linking to someone else’s code. The prefix should be the company name or the project initials. You’ll need to use the UpperCamelCase style. In this style, the first letter of the string is capital and the first letter of every string following is capitalized.

Example: class TASAwesomeClass

Constants (let) and variables (var)

We use the lowerCamelCase style in a combination with nouns when naming constants and variables. That means that the first letter of the string is lowercase, and the first letter of every string afterward is capitalized. Like camel humps.

Example: let thisBlogIsTotallyAwesome = true

Functions (func)

We use verbs written in lowerCamelCase, for naming functions usually. Pro Tip: functions should only do one thing, very well.

Example: func doOneThingWell

Enumerations (enum)

In this case, we use a noun written in UpperCamelCase.

Example: enum SomeEnumeration.


When matching enum values with a switch statement, we use a noun written in lowerCamelCase.

Example: switch awesomeBlogs

Structures (struct)

We use a noun drafted in UpperCamelCase when naming structures.

Example: struct SomeStructure

Extension (extension)

Same as structures, we use a noun drafted in UpperCamelCase for naming extensions.

Example: extension SomeType

Protocol (protocol)

We frequently use the suffix “able” such as in “Hashable” or “Equatable”, when naming protocols. A noun or a verb is used as the base.

Example: protocol Hashable

You might be interested in Swift 4 – Top 3 new String API features

Leave a Reply

Your email address will not be published. Required fields are marked *