Code Structure
Structuring code in a way that is easy to navigate allows for a greater developer experience. In order to achieve this, there are some guidelines to consider.
- Fields in all structures should be alphabetical
- Functions should be declared by the weight of their purity e.g.
read & writefirstreadsecondpurelast
- Structures should be grouped into modules and the content inside should be alphabetically ordered
- Dependencies and imports should be alphabetical
- Document the parameters of the interface in alphabetical order and preferably declare them in the same order in the function signature
An important aspect to remember is to use the formatter(s) to format the code prior to a commit.
cargo fmtto formatRustfilesforc fmtto formatSwayfiles