Naming convention for id

Hi,

I often have id columns and confused whether to use bookID or bookId?

It is a new swift project.

Swift style is to upper case initialisms, whether an acronym or abbreviation. So it’s ID. It also keeps pronounced acronyms uppercase, like NASA, like in American English.

3 Likes

Thank you so much for that clarification. such a relief to know bookID style is preferred.

I am assuming it is ok to use let id = UUID()as variable names start with lowercase.

Is there any Swift / Apple API using such style or any mention of it in the Swift API guidelines?

This is what I would do, but not all Apple APIs do this, e.g. the enum case UUIDAttributeType. (The other members of that enum start with a lowercase letter.)

1 Like

I think ID is the only initialism that is an abbreviation instead of an alphabetism. Is there another?

bookId and updateRestApiUrl are the preferred style

Here are the API Design Guidelines, under “Follow case conventions”

Acronyms and initialisms that commonly appear as all upper case in American English should be uniformly up- or down-cased according to case conventions

2 Likes

Thanks a lot @jjatie was very helpful, just quoting the relevant text:

Acronyms and initialisms that commonly appear as all upper case in American English should be uniformly up- or down-cased according to case conventions:

var utf8Bytes: [UTF8.CodeUnit]
var isRepresentableAsASCII = true
var userSMTPServer: SecureSMTPServer