Choose specific, descriptive names for variables, functions, and parameters that clearly communicate their purpose and content. Avoid generic terms that could be ambiguous or misleading.
Key principles:
Examples of improvements:
// ❌ Generic and potentially misleading
const userInfo = rawBookingData.user;
const users = await prisma.user.findMany({...});
const redirectTo = userId;
// ✅ Specific and descriptive
const bookingSlug = rawBookingData.user;
const attendeesAvailability = await prisma.user.findMany({...});
const redirectToUserId = userId;
Avoid naming conflicts:
// ❌ Confusing - boolean vs string with same base name
customLabel: true, // boolean property
customLabel: "My Label" // string in options
// ✅ Clear distinction
supportsCustomLabel: true, // boolean property
customLabel: "My Label" // string in options
This practice improves code readability, reduces cognitive load, and prevents misunderstandings about data types and purposes.
Enter the URL of a public GitHub repository