6  Project Organisation

Authors

Dan Cummins

Michael Tso

Gaurav Bhalerao

Paddy Roddy

David Wilby

Published

3 May, 2024

6.1 Directory Structure

One thing that makes a project difficult to reproduce is a disorganised project folder. Adhering to a consistent structure convention mitigates others from opening the project folder to find a big heap of confusingly named scripts.

Use folders/directories to organise your project, so that it is obvious (to you and anyone else who uses your code) where to find what is needed.

At the very top level of your project, why not have something like the following structure?

├── source/           # source code
│   ├── @MyClass/     # a class directory
│   ├── a_module/     # a directory containing a group of functions or classes with some commonality
│   └── utils/        # a directory containing utility functions, for example
├── data/             # directory to contain your data
│   ├── raw/          # all your raw, unprocessed data
│   └── processed/    # any data that you have altered
├── output/           # directory to contain your output
│   ├── figures/      # keep the figures that you produce from your code here
│   └── reports/      # a clear folder for your papers or reports for the project
├── docs/             # documentation
├── tests/            # software tests for the project
├── README            # readme file! (essential)
└── LICENSE           # license file (essential)

This structure follows several conventions that are common across languages, such as keeping a README file in the top-level of your project’s directory where users expect to find it, keeping your source code in a directory named source and your data and outputs separate from the code.

Note

This type of structure works well for relatively straightforward projects such as a piece of analysis or simulation, but if you’re building a package, toolbox or similar, there will be more appropriate and conventional structures to use.

6.1.1 Templates

One way of saving time is to make use of a project template, we have made one available on GitHub here: matlab-project-template which contains this directory structure as a template with placeholder information, designed specifically for MATLAB projects.

If you’re not familiar with Git, you can download this repository as a ZIP file, or just make it yourself in your project by creating the relevant directories.