Choose names that are both semantically accurate and consistent with established patterns. Names should clearly convey their purpose, data type, and behavior while following existing conventions in the codebase and upstream dependencies.
Choose names that are both semantically accurate and consistent with established patterns. Names should clearly convey their purpose, data type, and behavior while following existing conventions in the codebase and upstream dependencies.
Key principles:
CheckSwitchNameValid
returning an error message vs IsSwitchNameValid
returning boolean)reasons
for a vector, not reason
)Example:
// Better: Descriptive and indicates return type
std::optional<std::string_view> CheckSwitchNameValid(std::string_view key) {
if (!std::ranges::none_of(key, absl::ascii_isupper))
return "Switch name must be lowercase";
return {};
}
// Better: Plural name for collection parameter
void OnWindowEndSession(const std::vector<std::string> reasons) {
// ...
}
Enter the URL of a public GitHub repository