avatarDr. Derek Austin 🥳

Summary

The web content discusses the use of SCREEN_CASE (or SCREAM_CASE) in programming, which denotes constants by using all capital letters with underscores, a convention inspired by screenwriting practices, despite potential readability concerns and the availability of alternatives like the const keyword in JavaScript.

Abstract

The article "What Is Screen Case in Computer Programming? (SCREEN_CASE)" explains that in programming, SCREEN_CASE is a naming convention where constants are written in all uppercase letters separated by underscores. This practice, though less legible, is meant to clearly distinguish constants from other variables, drawing inspiration from the world of screenwriting, where new characters and certain other words are presented in all caps. The Python Style Guide endorses this convention for defining module-level constants, such as MAX_OVERFLOW and TOTAL. However, studies suggest that all-caps text is less legible, prompting some programmers to question the use of SCREEN_CASE for constants. The article acknowledges that while SCREEN_CASE is a common convention, it is not a strict rule, and developers are free to use other methods, like the const keyword in JavaScript, to declare constants. It also notes that JavaScript's const does not ensure complete immutability, as the contents of const objects can still be altered. For true immutability, the article suggests using libraries like immer. The author, Dr. Derek Austin, expresses a personal preference for SCREEN_CASE due to its clarity in signaling constants and highlighting "magic numbers," but also accepts that others may prefer different conventions.

Opinions

  • The author, Dr. Derek Austin, prefers SCREEN_CASE for constants as it clearly communicates their unchanging nature and helps identify "magic numbers."
  • There is an acknowledgment that SCREEN_CASE may reduce readability, based on research indicating that all-caps text is less legible.
  • The use of SCREEN_CASE is presented as a convention rather than a strict rule, allowing for personal preference and alternative practices.
  • The article suggests that JavaScript's const keyword, while useful for defining constants, does not prevent the mutation of object properties, and true immutability requires additional measures or libraries like immer.
  • The author is open to the use of SCREAM_CASE as an alternative naming convention, recognizing that the distinction between SCREEN_CASE and SCREAM_CASE is mostly semantic and that either term is acceptable in programming contexts.

What Is Screen Case in Computer Programming? (SCREEN_CASE)

For programming, ALL CAPS ISN’T YELLING, but it is less legible. SCREEN_CASE is commonly used for constants.

Photo by Waldemar Brandt on Unsplash

Take a look at the following code, and tell me if you can find the variable that I don’t want you to change:

Did you catch the hint from the capital letters separated by underscores? Using all uppercase is called screen case (or SCREEN_CASE).

The term comes from screenwriting, where newly-introduced characters appear in all caps, along with certain other words.

In software engineering, SCREEN_CASE is a programming convention to signify constants — variables that shouldn’t change:

“Constants are usually defined on a module level and written in all capital letters with underscores separating words. Examples include MAX_OVERFLOW and TOTAL.” — Python Style Guide

However, just like ALL CAPS IS SHOUTING ONLINE, you might want to avoid SCREEN_CASE for maximum readability:

“There is evidence [1] to show that all-caps is less legible and less readable than lower case. So constants are harder for us to read.” — Joseph Wilk

Using screen case is just a convention, not a rule. If you have a different personal preference for constants, go for it!

For example, you might use the const keyword in JavaScript. Just remember that JavaScript objects defined with const can have their contents changed, but nothing else can be assigned to that variable name:

(For truly immutable JavaScript objects that can’t be changed you’d need to use something like immer.)

Personally, I like SCREEN_CASE, because it makes me think “CONSTANT!” Plus, it’s a great way to point out magic numbers —numbers that are just hanging out in the code and need clarification.

But, you might hate screen case, and I’m fine with that too. 😛

WAIT: What Is SCREAM_CASE in Programming?

You may have heard the term SCREAM_CASE used instead of SCREEN_CASE, which sound almost the same when spoken out loud.

Honestly either name is fine with me. While the origin in screenwriting makes a lot of sense, I couldn’t find a programming source for it.

So if you think ALL_CAPS is indeed yelling then — by all means — please write all of your constants in SCREAM_CASE, not SCREEN_CASE.

Happy coding! 🤩🧐🐱‍👤🦄🐦

Dr. Derek Austin is the author of Career Programming: How You Can Become a Successful 6-Figure Programmer in 6 Months, now available on Amazon.

Programming
Software Engineering
Software Development
JavaScript
Web Development
Recommended from ReadMedium