Reputation: 1231
Say I have an acronym/abbreviation like AB.
Is there a convention for how the variable should be named if it is the first word of a camelCase?
In other words should it be * abTest * ABTest * AbTest
What if the acronym is more than 2 letters? Then should it be * httpTest * HttpTest
I know consistency is key, but if starting out, I feel perhaps the first option would be best?
Upvotes: 4
Views: 3131
Reputation: 121
I wish there were a good answer. It seems that acronyms that are more commonly used (and longer) are only capitalized on the first letter but shorter, less common ones are capitalized entirely. For instance, in JavaScript, one common object for HTTP requests is XMLHttpRequest
. While XML
is a shorter term (and needs to be capitalized to recognize easier, HTTP
is a longer and more recognizable term. Also, consider that it would be really irritating to write/read XMLHTTPRequest
as it would be pretty unreadable. Just make sure you're consistent and your variable names are readable.
Upvotes: 3