Naming Convention
A naming convention is a set of rules used to standardize how code is written.
CapitalCase
Structs, traits, and enums are CapitalCase
which means each word has a capitalized first letter. The fields inside a struct should be snake_case and CapitalCase
inside an enum.
struct MultiSignatureWallet {
owner_count: u64,
}
trait MetaData {
// code
}
enum DepositError {
IncorrectAmount: (),
IncorrectAsset: (),
}
snake_case
Modules, variables, and functions are snake_case
which means that each word is lowercase and separated by an underscore.
Module name:
library;
Function and variable:
fn authorize_user(user: Identity) {
let blacklist_user = false;
// code
}
SCREAMING_SNAKE_CASE
Constants are SCREAMING_SNAKE_CASE
which means that each word in capitalized and separated by an underscore.
const MAXIMUM_DEPOSIT = 10;