Class Names Standard
In our codebase, class names MUST be declared using PascalCase. This convention aids in distinguishing class names from other types of identifiers at a glance.
Definition
PascalCase means starting each word with a capital letter, without spaces or underscores between words. It's also known as Upper Camel Case.
Example (Correct):
public class CustomerAccount {
// Class name is in PascalCase
}
public class ShoppingCart {
// Class name is in PascalCase
}
Example (Incorrect):
public class customerAccount {
// Not using PascalCase
}
public class shopping_cart {
// Not using PascalCase
}
Method Names Standard
For clarity and consistency, method names MUST be declared in camelCase. This standard applies across all our codebases, irrespective of the programming language.
Definition
camelCase starts with a lowercase letter, and each subsequent word starts with a capital letter, without spaces or underscores.
Example (Correct):
public void updateAccountBalance() {
// Method name is in camelCase
}
private void saveUserPreferences() {
// Method name is in camelCase
}
Example (Incorrect):
public void UpdateAccountBalance() {
// Not using camelCase
}
private void save_user_preferences() {
// Not using camelCase
}
Constant Names Standard
Constants within our codebase MUST be declared using SCREAMING_SNAKE_CASE to easily differentiate them from other types of variables.
Definition
SCREAMING_SNAKE_CASE involves writing all letters in uppercase, with underscores separating words.
Example (Correct):
public static final int MAX_USER_COUNT = 100;
private static final String API_KEY = "your-api-key-here";
Example (Incorrect):
public static final int MaxUserCount = 100; // Not using SCREAMING_SNAKE_CASE
private static final String apiKey = "your-api-key-here"; // Not using SCREAMING_SNAKE_CASE
Variable Names Standard
To maintain a consistent and readable codebase, all variable names MUST be declared in camelCase. This convention applies to local and global variables alike.
Definition
camelCase for variable names starts with a lowercase letter, with each subsequent word beginning with an uppercase letter, without spaces or underscores.
Example (Correct):
int accountBalance;
String userName;
Example (Incorrect):
int AccountBalance; // Not using camelCase
String user_name; // Not using camelCase