Programming style rules
Clean code, happy life.
- General
- Bash
- Python
- R
General
- Save files in Unicode (UTF-8), Unix (LF).
- Preferred editors are BBEdit, Sublime Text, Emacs, or vim.
- Indent with 4 spaces, auto-expand tabs.
- Maximum of 80 characters per line.
- snake_case for file names.
- Avoid abbreviations and acronyms whenever possible (e.g.
identifier
instead of id
).
- Variables with single word acronyms should be lowercase (e.g.
rna
instead of RNA
).
- Write code using RStudio. It has great built-in support for proper indentation and RMarkdown.
- Follow the Bioconductor style guide for package development.
- Hadley’s style guide is also a useful general style reference.
- Periods are reserved for base R definitions.
- Use descriptive variable names.
- Avoid naming variables after functions, whenever possible.
- Use nouns for variables, verbs for functions.
- Use spaces in between definitions.
- camelCase all variable names, including acronyms.
- For logicals, explicitly write out
TRUE
and FALSE
, instead of using T
and F
.