Anyone know the rule for naming fields with the abbreviation "ID?"

I notice that MS is inconsistent, they have "PlatformID" and "ApplicationId."

I thought the rule was is the abbreviation was 3 characters or more, only the first letter is capitalized. Like Guid instead of GUID?

Recommended Answers

All 4 Replies

There are no strict rules, but more conventions.
You can follow them or not.
The only convention that is followed, with as far as I know, no exception, is that the name of an interface class starts with a capital I.

There are no strict rules, but more conventions.
You can follow them or not.
The only convention that is followed, with as far as I know, no exception, is that the name of an interface class starts with a capital I.

True. I guess I was asking what the popular convention is?

True. I guess I was asking what the popular convention is?

There are a variety of conventions, none of which is overwhelmingly popular over all the others... since we're talking about C#, you could use Microsoft's official guidelines. Wikipedia has a more general discussion of various styles.

With respect to the inconsistency you mention, the Microsoft standard says:

The two abbreviations that can be used in identifiers are ID and OK. In Pascal-cased identifiers they should appear as Id, and Ok. If used as the first word in a camel-cased identifier, they should appear as id and ok, respectively.

By their own standard, PlatformID is incorrect, but I prefer it over PlatformId because the latter always reminds me of the id monster.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.