Best practices
-
Separation of concerns - Each section of a program addresses a specific, distinct feature and these features are kept separate.
-
Principle of least privilege - Code should only have access to what it needs to have access to.
-
Principle of least surprise - The layout or functionality of the code is what the reader would expect.
-
Libraries - It's good to use libraries instead of implementing something yourself.
-
Explicit import - Instead of importing an entire module, list the functions you want to use.
-
Explicit export - When writing a module, only export the functions you want to be accessible.
-
Do not write partial functions - Functions like
headmay sometimes throw an error instead of returning a value. Write functions which return a value wrapped inMaybeorEitherinstead.