Menu

Naming Things: When to Use camelCase, snake_case, kebab-case, and PascalCase
πŸ“°
0

Naming Things: When to Use camelCase, snake_case, kebab-case, and PascalCase

DEV CommunityΒ·Ashish KumarΒ·about 1 month ago
#cDHrBuno
Reading 0:00
15s threshold

There are two hard problems in computer science: cache invalidation, naming things, and off-by-one errors. The naming-things one is the only one we can actually argue about all afternoon, so we do. This post is a practical reference for when each casing convention is correct, where they collide (databases meet APIs meet frontends meet URLs), and how to handle the conversions without sprinkling _.camelCase() calls across your codebase like prayers. The five conventions you'll see Convention Example Where it lives camelCase userEmail JavaScript variables, JSON keys, Java/Swift methods PascalCase UserEmail Class names, type names, React components, C# everything snake_case user_email Python variables, SQL columns, Ruby methods, env vars (sort of) kebab-case user-email URLs, CSS classes, HTML attributes, file names, npm packages SCREAMING_SNAKE_CASE USER_EMAIL Constants, environment variables That's the picture.…

Continue reading β€” create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.

Read More