Choose names that clearly communicate the intent, behavior, and semantics of code elements. Names should be accurate, consistent, and follow established patterns:
Choose names that clearly communicate the intent, behavior, and semantics of code elements. Names should be accurate, consistent, and follow established patterns:
Method names must reflect what they operate on: If a method manipulates indices, name it accordingly (e.g., moveIndicesToPreviouslyFailedStep
rather than moveClusterStateToPreviouslyFailedStep
). Method names should express what they do, not how they do it.
// Unclear - doesn't specify these are averages
int percentWriteThreadPoolUtilization;
long maxTaskTimeInWriteQueueMillis;
// Clear - precisely describes the metrics
int averageWriteThreadPoolUtilization;
long averageWriteThreadPoolQueueLatency;
// Hard to maintain - string literals scattered throughout code
if (configs.group.equals("unsupported") || configs.group.equals("union-types")) {
// Better - using named constants
private static final String GROUP_UNSUPPORTED = "unsupported";
private static final String GROUP_UNION_TYPES = "union-types";
if (configs.group.equals(GROUP_UNSUPPORTED) || configs.group.equals(GROUP_UNION_TYPES)) {
Enter the URL of a public GitHub repository