What’s in a name?

Me: Yo, bot. I need a cheatsheet because I’m bouncing between Ruby, Go, and JavaScript a lot in my new role at work. In software development what are all the most common cases and their definitions such as snake case, pascal case, kebab case. List t…


This content originally appeared on DEV Community and was authored by Michael Lang

Me: Yo, bot. I need a cheatsheet because I'm bouncing between Ruby, Go, and JavaScript a lot in my new role at work. In software development what are all the most common cases and their definitions such as snake case, pascal case, kebab case. List the name for the casing, the definition, an example, the top 5 languages that uses it, whether it applies to the code/source file itself or is use in naming of the source file. where applicable, include Ruby, Go, Node.js

Da Bot: Here’s a list of common naming conventions (casing styles) in software development, along with their definitions, examples, usage in different languages, and their applicability to code and source files.

1. Snake Case

  • Definition: All letters are lowercase with words separated by underscores (_).
  • Example: example_variable_name
  • Top 5 Languages: Python, Ruby, Go, Node.js, C
  • Application: Used in code (variables, functions), sometimes in naming source files.

2. Pascal Case

  • Definition: Each word is capitalized with no spaces or separators; the first letter of the identifier is capitalized.
  • Example: ExampleVariableName
  • Top 5 Languages: C#, Delphi, Swift, Java, Go
  • Application: Primarily used in code (class names, constants), not commonly in naming source files.

3. Camel Case

  • Definition: Similar to Pascal Case, but the first letter is lowercase.
  • Example: exampleVariableName
  • Top 5 Languages: JavaScript (Node.js), Java, C++, Go, Python
  • Application: Used in code (variables, functions), rarely in naming source files.

4. Kebab Case

  • Definition: All letters are lowercase with words separated by hyphens (-).
  • Example: example-variable-name
  • Top 5 Languages: HTML/CSS, JavaScript (Node.js), Ruby (for file names), URL paths
  • Application: Common in file and directory names, URLs, less often in code.

5. Screaming Snake Case (Constant Case)

  • Definition: All letters are uppercase with words separated by underscores (_).
  • Example: EXAMPLE_VARIABLE_NAME
  • Top 5 Languages: C, C++, Python, Ruby, Java
  • Application: Typically used for constants in code.

6. Lowercase

  • Definition: All letters are lowercase with no separators.
  • Example: examplevariablename
  • Top 5 Languages: C, Unix/Linux file systems, Go, Node.js (sometimes for package names)
  • Application: Sometimes used in file names and identifiers, especially in languages with fewer naming constraints.

7. Uppercase

  • Definition: All letters are uppercase with no separators.
  • Example: EXAMPLEVARIABLENAME
  • Top 5 Languages: SQL, C, C++, Assembly, sometimes in Node.js (for global constants)
  • Application: Used in constants, database schema definitions, sometimes in code.

8. Dot Notation

  • Definition: Words are separated by periods (.).
  • Example: example.variable.name
  • Top 5 Languages: JavaScript (Node.js), Python, Java, C#, TypeScript
  • Application: Commonly used in namespacing, object property access, package names.

9. Train Case (Upper Camel Case with Spaces)

  • Definition: Similar to Pascal Case, but with spaces between the words, and the first letter of each word is capitalized.
  • Example: Example Variable Name
  • Top 5 Languages: Markdown, documentation formatting, sometimes in JavaScript for display names
  • Application: Not used in code, but often seen in documentation and UI elements.

10. Hungarian Notation

  • Definition: Prefixes denote the type or scope of the variable, followed by the variable name in Camel Case or Pascal Case.
  • Example: strExampleVariableName (where str indicates a string)
  • Top 5 Languages: C++, C#, old VB.NET, Delphi, occasionally in Python
  • Application: Used in code, especially in older codebases; rarely in modern practice.

11. Macro Case

  • Definition: All letters are uppercase, with words separated by underscores. This is often seen in macros or compile-time constants.
  • Example: EXAMPLE_MACRO
  • Top 5 Languages: C, C++, Assembly, Objective-C, older C-like languages
  • Application: Primarily used in macros and preprocessor directives.

Each of these naming conventions has specific use cases in different programming languages, and they help maintain code readability and consistency. Some of these styles, like Kebab Case and Dot Notation, are more frequently used for file names or paths, while others like Snake Case and Camel Case are typically seen within the source code itself.


This content originally appeared on DEV Community and was authored by Michael Lang


Print Share Comment Cite Upload Translate Updates
APA

Michael Lang | Sciencx (2024-08-22T02:26:13+00:00) What’s in a name?. Retrieved from https://www.scien.cx/2024/08/22/whats-in-a-name-2/

MLA
" » What’s in a name?." Michael Lang | Sciencx - Thursday August 22, 2024, https://www.scien.cx/2024/08/22/whats-in-a-name-2/
HARVARD
Michael Lang | Sciencx Thursday August 22, 2024 » What’s in a name?., viewed ,<https://www.scien.cx/2024/08/22/whats-in-a-name-2/>
VANCOUVER
Michael Lang | Sciencx - » What’s in a name?. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2024/08/22/whats-in-a-name-2/
CHICAGO
" » What’s in a name?." Michael Lang | Sciencx - Accessed . https://www.scien.cx/2024/08/22/whats-in-a-name-2/
IEEE
" » What’s in a name?." Michael Lang | Sciencx [Online]. Available: https://www.scien.cx/2024/08/22/whats-in-a-name-2/. [Accessed: ]
rf:citation
» What’s in a name? | Michael Lang | Sciencx | https://www.scien.cx/2024/08/22/whats-in-a-name-2/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.