Conventions
The following recommendations are based on 2024 Move.
Add section titles
Use titles in code comments to create sections for your Move code files. Structure your titles using === on either side of the title.
module conventions::comments {
  // === Imports ===
  // === Errors ===
  // === Constants ===
  // === Structs ===
  // === Method Aliases ===
  // === Public-Mutative Functions ===
  // === Public-View Functions ===
  // === Admin Functions ===
  // === Public-Package Functions ===
  // === Private Functions ===
  // === Test Functions ===
}
CRUD functions names
These are the available CRUD functions:
- add: Adds a value.
- new: Creates an object.
- drop: Drops a struct.
- empty: Creates a struct.
- remove: Removes a value.
- exists_: Checks if a key exists.
- contains: Checks if a collection contains a value.
- destroy_empty: Destroys an object or data structure that has values with the drop ability.
- to_object_name: Transforms an Object X to Object Y.
- from_object_name: Transforms an Object Y to Object X.
- property_name: Returns an immutable reference or a copy.
- property_name_mut: Returns a mutable reference.
Potato structs
Do not use 'potato' in the name of structs. The lack of abilities define it as a potato pattern.
module conventions::request {
  // ✅ Right
  struct Request {}
  // ❌ Wrong
  struct RequestPotato {}
}