Explore best practices for naming files, functions, variables, and more in software development, with examples of good and bad practices.
UserProfile
UserSettings
PascalCase
or kebab-case
, depending on the project’s convention. Here’s how I would incorporate this into the document:
PascalCase
or kebab-case
can be used.
kebab-case
for folder names.snake_case
, kebab-case
, or inconsistent capitalization in component filenames.
kebab-case
and camelCase
. The key is to maintain consistency throughout the project. Choose one style and stick with it.
| Good Practice ✅
kebab-case
or camelCase
for naming hooks, utilities, types, and other similar files in your project. Do not mix these conventions within the same codebase.
The choice may depend on team preferences, the specific needs of the project, or existing conventions in related projects. Remember, consistency is paramount.
Case Style | Usage |
---|---|
camelCase | Object keys, function names, variables, React state variables, method names in classes |
PascalCase | Class names, constructor functions, React component names, interface names (in languages like TypeScript) |
snake_case | Database fields, database table names, variable and function names in Python |
kebab-case | CSS class names, file names, URL slugs |
UPPER_CASE_SNAKE_CASE | Constants, environment variable names |
Hungarian Notation | Prefixing variable names with type indicators (less common) |