Variable, method, and type names should accurately reflect their actual purpose, content, and behavior. Avoid generic or misleading names that don’t match the underlying functionality.
Key principles:
visible_input_methods not visible_input_method for a Vecclosed_any_websocket not canceled_any_fetch when closing websocketshit_test_result not cached_hit_test_result when it’s not always cachedarea not size when measuring area specificallyExample:
// Bad - misleading name
let cached_hit_test_result = match event.event { ... }
// Good - accurate name
let hit_test_result = match event.event { ... }
// Bad - singular for collection
visible_input_method: Vec<EmbedderControlId>,
// Good - plural for collection
visible_input_methods: Vec<EmbedderControlId>,
Names should immediately communicate what the code actually does, not what it might do or what it was originally intended to do.
Enter the URL of a public GitHub repository