This cheatsheet is, shockingly, for programmers using programming languages to program.
Below are examples of the best naming conventions used in the programming world.
Note
You may have different thoughts on this, but they are wrong.
It's time to get with the program... ☜(⌒▽⌒)☞
These are the naming conventions that have bubbled-up through the decades as the most
proficient and ideal, which is why they are some common today.
So stick with them so we can all read code easier together!
Convention | Example #1 | Example #2 | Aliases |
---|---|---|---|
camelCase |
listenerHTTP |
graphQLHelper |
dromedaryCase |
PascalCase |
ListenerHTTP |
GraphQLHelper |
ProperCase |
snake_case |
listener_http |
graph_ql_helper |
|
kebab-case |
listener-http |
graph-ql-helper |
caterpillar-case |
CONSTANT_CASE |
LISTENER_HTTP |
GRAPH_QL_HELPER |
SCREAMING_CASE |
Tip
File Names
kebab-case
is the universal ideal for the names of files and their extensions following a dot separator.
✗MY FILE NAME.md
✗My Proper File.md
my-proper-file.md
✔
As you can see, that is 6 solid conventions that work great in nearly all situations. There is not a need for any new ones, they've all been tried by us programmers in the decades past.
Stop. Wasting. Everyone's. Time. and just stick to these.
The following convensions are generally discouraged or considered legacy/not-ideal.
Some developers like to waste time by creating conventions that are a modification of those listed here, often
calling out an UPPER
or lower
version as to indicate their new standard. This is stupid.
Here's a few more conventions that can now be classified as such in the modern era:
Convention | Example #1 | Example #2 | Aliases | Use Instead |
---|---|---|---|---|
COBOL-CASE |
LISTENER-HTTP |
GRAPH-QL-HELPER |
➔ CONSTANT_CASE |
|
dot.case |
listener.http |
graph.ql.helper |
➔ kebab-case |
|
lazyCamelCase |
listenerHttp |
graphQlHelper |
➔ camelCase |
|
Pascal_Snake_Case |
Listener_HTTP |
Graph_QL_Helper |
Proper_Snake_Case |
➔ snake_case |
Train-Case |
Listener-HTTP |
Graph-QL-Helper |
HTTP-Header-Case |
➔ kebab-case |
In legacy codebases, you may find prefixes or suffixes to naming conventions used in a haphazard attempt to categorize variables. In many cases, the prefixes or suffixes are made (a poor choice of) convention by a library or framework.
Use instead proper architecture, convention, and documentation (such as JSDoc).
Notation | Example #1 | Example #2 | Aliases |
---|---|---|---|
__IDENT__ |
__LISTENER_HTTP__ |
__GRAPH_QL_HELPER__ |
|
$JQuery |
$listenerHttp |
$graphQlHelper |
|
_privateNotReally |
_listenerHttp |
_graphQlHelper |
If you find yourself doing this in a modern project... stop.
Now we can all get back to coding.