# 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:** 4

<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, 9:31pm UTC](https://discourse.julialang.org/t/best-practise-organising-code-in-julia/74362/4 "2022-01-11T21:31:24Z")

</div>

> [@jzr](#):
>
> OP wants to download and analyze some data. What is the benefit of using a module here?

Presumably, they want to do a similar analysis more than once — if @roh_codeur is asking about large-scale code organization, they must not be talking about a one-time throwaway script. If they have a non-trivial amount of code, separating it in a package makes it **easier to re-use** in multiple different projects.

That is, create a MyDataAnalysis.jl package (hence a module) that has the re-usable parts of the analysis and data acquisition that you want to do. Then, for any particular project or task, write a script or Jupyter notebook etcetera that does:

```julia
using MyDataAnalysis # & other packages as needed ...

#... acquire some specific data ...
data = ...

# run some analysis
MyDataAnalysis.frobnicate(data)

```

> [@jzr](#):
>
> Modules make it harder to selectively execute code.

To selectively execute code (i.e. re-use pieces), the best approach in the long run is generally to separate it into _functions_ that you call individually, not by commenting out or selectively executing sections in a big script — that way lies madness for large projects.

For small throw-away scripts, of course, I agree — just make a Pluto/Jupyter notebook or similar and edit/execute it in chunks until it does what you want.

---

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