Choose variable, function, and method names that clearly communicate their purpose and behavior. Avoid ambiguous abbreviations, numbered suffixes, double negatives, and names that don’t accurately reflect functionality.
Key principles:
preemptorPodPriority
instead of podPriority
, candidateHyperNodes
instead of reScoreHyperNodes
ok
instead of ok1
nodeIsReady
instead of !nodeIsNotReady
filterVictimsFn
not preemptable_reclaimable_fn
)checkNodeGPUSharingPredicateWithScore
Example:
// Poor naming
func (pmpt *Action) taskEligibleToPreemptOthers(preemptor *api.TaskInfo) (bool, string) {
podPriority := PodPriority(preemptor.Pod) // Unclear whose priority
// ...
}
// Better naming
func (pmpt *Action) taskEligibleToPreemptOthers(preemptor *api.TaskInfo) (bool, string) {
preemptorPodPriority := PodPriority(preemptor.Pod) // Clear ownership
// ...
}
Clear naming reduces cognitive load, prevents misunderstandings, and makes code self-documenting for future maintainers.
Enter the URL of a public GitHub repository