DEV Community


Discussion on: A Grammar-Based Naming Convention

theodesp profile image
Theofanis Despoudis

I would avoid uppercase variable names completly.Nowdays every editor can highlight constants plus they look better in the eye

somedood profile image
Basti Ortiz (Some Dood) Author

Well, for me, I find SCREAMING_CASE pretty helpful because it's literally screaming at me not to do anything stupid with it. Even if my text editor highlights constants differently, there would be less "visual aid" for me to see that a variable is indeed a constant.

// To me, this communicates its intent better...

// ...than this.
const dontDoAnythingDumbPls = 0;

// ...or this.
const dont_do_anything_dumb_pls = 0;

Honestly, it's just a matter of personal preference. The whole point of this article is "being able to communicate your intent" after all. I do get your point, though. It can get pretty intimidating to see variables screaming at your face. Although it is ugly, I have to live with it just so I can have the benefits of "visual aid" in addition to its distinct syntax highlighting.

Now that I think about it, since most variables in JavaScript nowadays are immutable (as good practice), the syntax highlighting might not even help me at all. All of my variables would literally be highlighted the same way, which ultimately defeats its purpose. I guess the SCREAMING_CASE serves as an additional line of defense for me in this case.