Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should acronym be capitalized in camelcase if first word of camelCase?

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?

like image 751
writofmandamus Avatar asked Oct 19 '25 06:10

writofmandamus


1 Answers

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.

like image 137
Furkan Toprak Avatar answered Oct 22 '25 04:10

Furkan Toprak



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!