Prompt
Names should accurately reflect their purpose, behavior, and semantic meaning to avoid confusion and improve code readability. Avoid misleading names that don’t match the actual functionality or content.
Key principles:
- Function names should match their actual behavior (e.g.,
projectCorrelatedColumnswhen called with non-correlated data should be renamed to reflect what it actually does) - Variable names should be specific and unambiguous (e.g.,
cached_readeris misleading when it specifically refers toCachedInMemoryReadBufferFromFile- usepage_cache_readerinstead) - Parameter names should clearly indicate their role (e.g.,
column_idxshould bepresence_column_idxif it’s specifically the index of a presence column) - Avoid abbreviations that sacrifice clarity (e.g., use
storageortableinstead oftbl) - Method names should indicate what they return or do (e.g.,
getHivePart()should be split into separate methods if it also performs normalization)
Example of improvement:
// Before: misleading name
void projectCorrelatedColumns(rhs_plan, ...); // but no correlation involved
// After: accurate name
void projectIdentifierColumns(rhs_plan, ...); // clearly indicates projecting from identifiers
// Before: ambiguous variable
auto * cached_reader = typeid_cast<CachedInMemoryReadBufferFromFile *>(&reader);
// After: specific variable
auto * page_cache_reader = typeid_cast<CachedInMemoryReadBufferFromFile *>(&reader);
This ensures that code is self-documenting and reduces cognitive load when reading and maintaining the codebase.