Choose clear, self-documenting names for variables, methods, parameters, and properties that explicitly convey their purpose and context. Avoid ambiguous or generic names that require additional context to understand.
Choose clear, self-documenting names for variables, methods, parameters, and properties that explicitly convey their purpose and context. Avoid ambiguous or generic names that require additional context to understand.
Key principles:
_OnTabClick
instead of _OnClick
)SendKeyDownEvent()
instead of SendKeyEvent(vkey, scanCode, flags, true)
)charSizeInDips
vs charSizeInPixels
)Example improvements:
// Instead of:
_terminal->SendKeyEvent(vkey, scanCode, flags, true);
tabViewItem.PointerReleased({ this, &TerminalPage::_OnClick });
// Use:
_terminal->SendKeyDownEvent(vkey, scanCode, flags);
tabViewItem.PointerReleased({ this, &TerminalPage::_OnTabClick });
// Instead of:
double PaddingValueFromIndex(const winrt::hstring& paddingString, uint32_t paddingIndex)
// Use:
double PaddingValueFromIndex(const winrt::hstring& paddingString, PaddingDirection direction)
This approach reduces cognitive load, makes code self-documenting, and prevents misuse of APIs by making intent explicit through naming.
Enter the URL of a public GitHub repository