domains / / ClickHouse/ClickHouse
semantic naming accuracy
Ensure that method, variable, and class names accurately reflect their actual behavior, purpose, or content. Names should semantically match what they represent to prevent confusion and bugs.
Ensure that method, variable, and class names accurately reflect their actual behavior, purpose, or content. Names should semantically match what they represent to prevent confusion and bugs.
Key principles:
- Method names should match their actual behavior:
detachX()should performget + cancel, not justcancel - Variable names should reflect their content:
patch_block_indicesnotpatch_col_indiceswhen indexing blocks - Class names should accurately describe their function:
SerializationnotCompressionwhen the class handles serialization - Method names should be descriptive of their purpose:
shouldSearchForPartsOnDisk()notlookOnDisk() - Use consistent, accurate terminology throughout:
disknotdrivewhen referring to storage disks
Example of problematic vs. corrected naming:
// Problematic - method name doesn't match behavior
void detachParallelReadingExtension(); // actually just clears/cancels
// Corrected - name matches actual behavior
void clearParallelReadingExtension(); // or implement proper detach semantics
// Problematic - variable name doesn't match content
PaddedPODArray<UInt64> patch_col_indices; // actually indexes blocks
// Corrected - name matches content
PaddedPODArray<UInt64> patch_block_indices;
This prevents misunderstandings about code behavior and makes the codebase more maintainable by ensuring names serve as accurate documentation of functionality.