DEV Community

Cover image for What's in a name?
Michael Lang
Michael Lang

Posted on

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 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.

Top comments (0)