Prompt
Names should clearly indicate their purpose and context to avoid confusion, especially when similar concepts exist in the same scope. Generic names like “api”, “params”, or “arg1” create ambiguity and make code harder to understand. Instead, use specific, meaningful identifiers that describe what they represent or do.
Examples of improvements:
- Change generic labels like “expand”/”collapse” to contextual ones like “Expand/collapse lists menu”
- Replace confusing names like
params(which resemblesuseParamshook) with descriptive alternatives liketarget - Use meaningful parameter names like
indexinstead of genericarg1,arg2 - Replace non-specific names like
apiwith descriptive alternatives that indicate their actual purpose
This practice becomes especially important when multiple similar concepts exist in the same scope, as clear naming prevents confusion and improves code maintainability.