Principles of Good Code Writing
A beginner-friendly guide for researchers to write clean, reproducible code.
Welcome!
This guide is for anyone writing code - even if you have zero formal programming training.
No prior experience required.
Simple, practical tips that apply to any language (Python, R, MATLAB, etc.).
Why This Guide Exists ๐ญ
Good code is like a well-organized lab notebook:
- Easier for you to understand later.
- Easier for others to reproduce your work.
- Ready for journals and funding agencies requiring open and reproducible research.
Table of Contents ๐
- Introduction
- What Makes Code Good?
- Naming Things Well
- Writing Readable Code
- Commenting and Documenting
- Breaking Code Into Chunks
- Core Coding Principles (DRY, KISS, YAGNI)
- Avoiding Common Mistakes
- Write Code Like a Lab Notebook
- Reproducibility in Practice
- Magic Numbers & Checks
- Reading Error Messages
- Cheat Sheet
- Emergency Fixes
How to Use This Guide
- Start with Introduction if youโre new to coding.
- Jump to any principle for quick tips and examples.
- Download the Cheat Sheet for a one-page summary.
โ Back to Research Skills Toolkit