Naming Conventions Guide: Choosing the Right Case for Your Code

May 28, 20266 min read

Why Naming Conventions Matter

Naming conventions are not cosmetic preferences. They affect how quickly you read code, how easily you spot bugs, and how smoothly your team collaborates. A consistent naming style lets your brain skip the "decode" step and focus on the logic.

Inconsistent naming wastes time. When one developer writes user_name and another writes userName, every reader pauses to check whether they refer to the same thing. Multiply that pause across thousands of variable reads per day, and the cost is real.

The Four Main Naming Styles

Most programming languages use one of four capitalization conventions. Each has a distinct look and common use cases.

camelCase

Words are joined without separators, and every word after the first starts with an uppercase letter.

let firstName = "Alice";
function calculateTotal() {}
const maxRetryCount = 3;

Used by: JavaScript, TypeScript, Java, C#, Go (for private fields)

PascalCase

Every word starts with an uppercase letter, including the first one.

public class UserProfile {}
public void ProcessOrder() {}

Used by: C#, Java (classes), TypeScript (types, interfaces, components), Go (exported identifiers)

snake_case

Words are joined with underscores, all lowercase.

first_name = "Alice"
def calculate_total():
    pass
MAX_RETRY_COUNT = 3

Used by: Python, Ruby, Rust (snake_case for functions and variables), SQL

kebab-case

Words are joined with hyphens, all lowercase.

.user-profile {}
font-size: 16px;

Used by: CSS class names, HTML attributes, URL slugs, file names in many JavaScript projects

Language-by-Language Recommendations

Every language has community conventions. Following them makes your code feel natural to other developers in that ecosystem.

LanguageVariables & FunctionsClasses & TypesConstantsFiles
JavaScriptcamelCasePascalCaseSCREAMING_SNAKEkebab-case
TypeScriptcamelCasePascalCaseSCREAMING_SNAKEkebab-case
Pythonsnake_casePascalCaseSCREAMING_SNAKEsnake_case
GocamelCase (unexported)PascalCase (exported)camelCasesnake_case
Rustsnake_casePascalCaseSCREAMING_SNAKEsnake_case
JavacamelCasePascalCaseSCREAMING_SNAKEPascalCase
C#camelCasePascalCasePascalCasePascalCase
Rubysnake_casePascalCaseSCREAMING_SNAKEsnake_case

Variables vs Constants vs Files

The same language often uses different conventions for different categories of identifiers.

Variables and functions follow the dominant style of the language (camelCase for JS, snake_case for Python). Constants almost always use SCREAMING_SNAKE_CASE across all languages:

const MAX_CONNECTIONS = 100;
const API_BASE_URL = "https://api.example.com";

File names are a common source of confusion. JavaScript projects typically use kebab-case for files (user-profile.vue, api-client.ts), even though the code inside uses camelCase or PascalCase. Python projects use snake_case (user_profile.py). Java and C# use PascalCase to match the class name (UserProfile.java).

Mixed Conventions in Practice

Some frameworks require mixing conventions. Here are the most common scenarios.

React Component Files

React components use PascalCase for the component name but kebab-case for the file name:

Components:
  user-profile.tsx → exports UserProfile
  navigation-bar.tsx → exports NavBar

This feels contradictory, but each convention serves a purpose: kebab-case file names work well with URL-based tooling and case-insensitive file systems, while PascalCase component names follow JSX requirements.

Go Visibility Rules

In Go, the capitalization of the first letter controls visibility:

type User struct {}      // exported (public)
type userSession struct {} // unexported (private)

func GetUserID() int {}   // exported
func validateInput() {}   // unexported

This is not a style choice — it is a language rule. The convention directly affects program behavior.

Database Columns vs Application Code

API responses often arrive in camelCase (from JSON), but database columns frequently use snake_case. You may need to transform names at the boundary:

# JSON arrives with camelCase
{"firstName": "Alice", "lastName": "Smith"}

# Python model uses snake_case
first_name = data["firstName"]
last_name = data["lastName"]

The Importance of Team Conventions

Community conventions provide a starting point, but team agreements override them. If your team decides on a style, document it and enforce it with tooling.

Linters and formatters are the most effective way to maintain consistency. ESLint can enforce camelCase variables. Pylint can enforce snake_case in Python. Prettier can normalize file naming.

A naming rule that is automated is a rule that is followed. A rule that relies on memory and code review will drift within weeks.

Key Takeaways

  • Consistent naming removes friction — your brain skips the decode step and reads logic directly.
  • Each language has dominant conventions; follow them unless your team agrees otherwise.
  • Constants use SCREAMING_SNAKE_CASE in nearly every language.
  • File names and code identifiers often follow different conventions — that is normal.
  • Mixed conventions (like React's kebab-case files + PascalCase components) are common and practical.
  • Automate enforcement with linters and formatters rather than relying on code review alone.

Try It Yourself

Need to convert naming styles quickly? These tools help:

  • Case Converter — Switch between camelCase, snake_case, PascalCase, and kebab-case instantly
  • Slug Generator — Create URL-friendly kebab-case slugs from any text