# Best practise: organising code in Julia

**URL:** <https://discourse.julialang.org/t/best-practise-organising-code-in-julia/74362>\
**Category:** New to Julia\
**Tags:** modules, code-organization\
**Created:** [January 10, 2022, 9:21pm UTC](https://discourse.julialang.org/t/best-practise-organising-code-in-julia/74362 "2022-01-10T21:21:34Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [January 11, 2022, 5:30pm UTC](https://discourse.julialang.org/t/best-practise-organising-code-in-julia/74362/2 "2022-01-11T17:30:45Z")

</div>

See many previous discussions: [Pros & Cons of using modules vs plain include?](https://discourse.julialang.org/t/pros-cons-of-using-modules-vs-plain-include/14694) and [Single module vs. submodules in a project](https://discourse.julialang.org/t/single-module-vs-submodules-in-a-project/55361) and [Large programs: structuring modules & include such that to increase performance and readability](https://discourse.julialang.org/t/large-programs-structuring-modules-include-such-that-to-increase-performance-and-readability/29102) and [What is the preferred way to use multiple files?](https://discourse.julialang.org/t/what-is-the-preferred-way-to-use-multiple-files/30687)

TLDR: Start with a single module in a single package, split into as many files as you want, and refactor as needed later on.

- [Create at least one package](https://pkgdocs.julialang.org/v1/creating-packages/) for any major project, so that you can benefit from the Julia package system and the tooling around it.
- The most common pattern is a single module per package, but split up the implementation into as many files as you want, and just `include` them from the top-level `MyPackage.jl` file. (Each file is included _once_. It is no problem to call code from one file in another file of the same module.)
  - The reason to use submodules within a package is if you are running into namespace collisions from different parts of your implementation, but you can always introduce submodules later if this becomes an issue.

- Generally, split your project into multiple packages once you have functionality that could reasonably be used on its own. You can always do this later.

(Use [Revise.jl](https://github.com/timholy/Revise.jl) during development, so that you can edit the package and execute the new code without having to re-load the whole package.)

---

_[View the full topic](https://discourse.julialang.org/t/best-practise-organising-code-in-julia/74362)._
