clean-code

Logo

Training materials and slides for courses on version control, clean code and documentation with practical examples and exercises in Python and R

View the Project on GitHub RISE-UNIBAS/clean-code

WWZ Workshop: Clean Code in Context

Agenda

Recap Crash Course

“I like my code to be elegant and efficient. The logic should be straightforward to make it hard for bugs to hide, the dependencies minimal to ease maintenance, error handling complete according to an articulated strategy, and performance close to optimal so as not to tempt people to make the code messy with unprincipled optimizations. Clean code does one thing well.

— Bjarne Stroustrup, inventor of C++

Reference: Martin, R. (2015): Clean Code. Upper Saddle River, NJ: Prentice Hall.

Why you should use clean code

Recap

Clean Code in Context: File Structure

file_structure

A good start, but not ideal.

Why File Structure?

Based on the MIT Communication Lab:

Why do it? The arguments for clean code apply here as well:

General Good Practices

Naming conventions

Examples

Instead of confusing names like final_final_thisone, consider: v1, v2, etc. Use YYYYMMDD for dates.

phd_comics

Folder structure

basic_folder_structure

Source: Claire Duvallet

simple_hierarchy

Source: Case studies from mitcommlab

File formats

LaTeX

File encoding

R Markdown

Integrating GitHub with RStudio

Follow the instructions here for GitHub-RStudio integration. This integration allows making commits directly via RStudio.

commit_from_rstudio

Examples & Resources