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
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: constantsPython:
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: constantsJava:
int maxRetryCount = 3; // camelCase: variables
void fetchUserProfile() { } // camelCase: methods
class OrderSummaryService { } // PascalCase: classes
static final int MAX_RETRIES = 3; // SCREAMING_SNAKE_CASE: constantsThe 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.
