Skip to content
Stephan Kulla edited this page May 10, 2023 · 20 revisions

General information

Clean code

Git Messages

Order source files from abstract to concrete

We follow the coding style that source code should be ordered (when possible) from abstract to concrete. An alternative description for this rules: Start with the most general concepts and go then to the concepts it depends on and then to those dependents. Example:

/* ✅ Good */
function main() {
  do_stuff()
}

function do_stuff() {
  do_more_concrete_stuff()
}

function do_more_concrete_stuff() {
  partey()
}

What we do not want to do:

/* ❌ Bad */
function do_more_concrete_stuff() {
  partey()
}

function do_stuff() {
  do_more_concrete_stuff()
}

function main() {
  do_stuff()
}

TypeScript / JavaScript

Testing

Rust

Take care that in assert_eq() the left value is the expected one

In order for us to better understand the code we follow the convention that the left value in assert_eq is the expected and the right value is the actual one. To quote ChatGPT:

In Rust, when using the assert_eq!() macro, there is no strict convention on which value should be on the left and which should be on the right. However, it is common practice to put the expected value on the left and the actual value on the right. This practice is mainly for readability purposes and to make it clear to other developers what the expected outcome is.

Clone this wiki locally