domains / / vadimdemedes/ink
Use descriptive parameter names
Choose parameter names that clearly communicate their purpose and avoid confusion with similar concepts. Avoid generic or ambiguous names that could be misinterpreted.
Choose parameter names that clearly communicate their purpose and avoid confusion with similar concepts. Avoid generic or ambiguous names that could be misinterpreted.
When naming parameters, consider:
- What the parameter actually represents, not just its technical type
- Whether the name could be confused with other common programming concepts
- If the parameter type changes, update the name to match
Example of unclear naming:
export function useInput(
inputHandler: (input: string, meta: Meta) => void
Better alternatives:
export function useInput(
inputHandler: (input: string, metadata: InputMetadata) => void
// or
inputHandler: (input: string, key: KeyInfo) => void
The name meta is ambiguous because it could be confused with “meta keys” (a different keyboard concept), while metadata or key clearly indicate what the parameter contains.