Prompt
Choose names that clearly communicate purpose, intent, and functionality rather than generic or abbreviated alternatives. Names should follow Rust conventions (snake_case for variables, functions, modules) and accurately describe what they represent or do.
Key principles:
- Use descriptive field names:
cw20_implinstead ofcw20_base - Method names should reflect their actual behavior:
GetStatusCommitmentinstead ofGetCommittedStatuswhen returning a hash commitment - Follow Rust naming conventions:
consensus_state_bytesnotconsensusStateBytes - Use proper types with semantic names:
AddressandB256instead of generic&[u8] - Choose meaningful type aliases: avoid generic names like
SharedMapwithout context
Example:
// Poor naming
pub fn new_beacon_light_client_update() -> BeaconUpdate { ... }
pub const UNION_IBC: &str = "union:union-ibc";
struct MsgCreateClient {
bytes consensusStateBytes; // camelCase, unclear
}
// Better naming
pub fn into_beacon_light_client_update() -> BeaconUpdate { ... }
pub const UNION_IBC: &str = "union:ibc-union";
struct MsgCreateClient {
bytes consensus_state_bytes; // snake_case, clear
}
Names are the primary way developers understand code intent - invest in clarity over brevity.