TC
ProgrammingJanuary 22, 2025·10 min read

The Complete Guide to Naming Conventions in Programming

Why Naming Conventions Matter

Consistent naming conventions make code more readable, maintainable, and professional. They signal to other developers (and your future self) what a piece of code does and how it should be used.


The Major Naming Conventions

1. camelCase

Words are joined with no spaces; each word (except the first) starts with a capital letter.

Example: firstName, getUserById, backgroundColor

Used in: JavaScript, TypeScript, Java, Swift, Kotlin, JSON


2. PascalCase (UpperCamelCase)

Same as camelCase but the first word is also capitalized.

Example: FirstName, GetUserById, BackgroundColor

Used in: Class names in all OOP languages, React components, C# methods, .NET conventions


3. snake_case

Words separated by underscores, all lowercase.

Example: first_name, get_user_by_id, background_color

Used in: Python (PEP 8), Ruby, SQL/databases, PHP, file names in Unix


4. SCREAMING_SNAKE_CASE (CONSTANT_CASE)

Like snake_case but ALL UPPERCASE.

Example: MAX_RETRY_COUNT, DATABASE_URL, API_KEY

Used in: Constants in Python, JavaScript, Java; environment variables; PHP constants


5. kebab-case (spinal-case)

Words separated by hyphens, all lowercase.

Example: first-name, background-color, user-profile

Used in: CSS class names, URL slugs, HTML data attributes, Lisp, some config files


6. COBOL-CASE (UPPER-KEBAB)

Like kebab-case but ALL UPPERCASE.

Example: FIRST-NAME, CUSTOMER-ACCOUNT-NUMBER

Used in: COBOL, some legacy mainframe systems


7. Train-Case (Pascal-Kebab)

PascalCase with hyphens.

Example: Content-Type, Accept-Encoding, X-Api-Key

Used in: HTTP header names (though headers are technically case-insensitive)


8. dot.case

Words separated by dots, all lowercase.

Example: com.example.app, app.settings.debug

Used in: Java package names, configuration properties, some build systems


9. flatcase

All words run together in lowercase with no separator.

Example: firstname, backgroundcolor

Used in: Some URL schemes, package names in Go


Quick Reference Table

ConventionExampleLanguage

|---|---|---|

camelCasemyVariableJS, Java, JSON
PascalCaseMyClassNameAll class names
snake_casemy_variablePython, Ruby, SQL
CONSTANT_CASEMY_CONSTANTConstants, .env
kebab-casemy-classCSS, HTML, URLs
COBOL-CASEMY-FIELDCOBOL
Train-CaseContent-TypeHTTP headers
dot.caseapp.config.keyJava packages

Best Practices

1. Be consistent — use one convention throughout a codebase (or follow the project's existing convention)

2. Follow the community standard — use what the language's community guide recommends

3. Be descriptivegetUserById is better than getUBI or g_u_b_i

4. Avoid abbreviationscustomerCount over custCnt

5. Use domain language — match terminology from the business domain