Script Valley
Writing Clean Code: Naming, Functions & Structure
Why Naming MattersLesson 1.5

Naming conventions by language: JavaScript, Python, and Java

camelCase, snake_case, PascalCase, SCREAMING_SNAKE_CASE, language-specific conventions, linter enforcement, team consistency

Language-Specific Naming Conventions

Naming conventions by language

Good naming principles are universal. Naming conventions are language-specific. Using the wrong convention in a language signals that you don't know the ecosystem โ€” and it breaks tool integrations like linters and documentation generators.

JavaScript:

const maxRetryCount = 3;           // camelCase: variables
function fetchUserProfile() { }    // camelCase: functions
class OrderSummaryService { }      // PascalCase: classes
const API_BASE_URL = "...";        // SCREAMING_SNAKE_CASE: constants

Python:

max_retry_count = 3                # snake_case: variables
def fetch_user_profile():          # snake_case: functions
    pass
class OrderSummaryService:         # PascalCase: classes
    pass
API_BASE_URL = "..."               # SCREAMING_SNAKE_CASE: constants

Java:

int maxRetryCount = 3;             // camelCase: variables
void fetchUserProfile() { }        // camelCase: methods
class OrderSummaryService { }      // PascalCase: classes
static final int MAX_RETRIES = 3;  // SCREAMING_SNAKE_CASE: constants

The most important rule: be consistent within a project. Mixed conventions in the same file are worse than consistently using the "wrong" convention.

Enforce conventions automatically. Use ESLint for JavaScript, Pylint or Black for Python, Checkstyle for Java. Don't make convention enforcement a code review conversation โ€” make it a build step. Code that violates conventions doesn't merge.

When joining an existing project, match whatever conventions are already in use before introducing your preferences.

Naming conventions by language: JavaScript, Python, and Java โ€” Why Naming Matters โ€” Writing Clean Code: Naming, Functions & Structure โ€” Script Valley โ€” Script Valley