# Proper way of organizing code into subpackages

**URL:** <https://discourse.julialang.org/t/proper-way-of-organizing-code-into-subpackages/52835>\
**Category:** New to Julia\
**Tags:** packages, code-organization\
**Created:** [January 4, 2021, 5:34pm UTC](https://discourse.julialang.org/t/proper-way-of-organizing-code-into-subpackages/52835 "2021-01-04T17:34:30Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![MA\_Laforge](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ma_laforge/32/385_2.png) [@MA\_Laforge](https://discourse.julialang.org/u/MA_Laforge)\
**Post date:** [January 4, 2021, 6:17pm UTC](https://discourse.julialang.org/t/proper-way-of-organizing-code-into-subpackages/52835/3 "2021-01-04T18:17:15Z")

</div>

### Tips: `include()`

- Do not use `include()` to “include” a package into your project.
- Actually, `include()` loads code from a file. I don’t think Python has such a low level command. In C/C++, it probably corresponds to what the linker does (Of course it also loads the code in memory).
- `include()` was meant to load code stored in _ **subfiles** _ (not submodules) - allowing you to break your solution up into multiple files.
- Only `include()` files that are directly part of your current package/project.
- Do not `include()` files from other “software modules” (projects).

### Tips: `module`

- `module MyMod` is not a “software module” as you likely think of it. It is simply a global namespace.
- You can have more than one `module` per file, and can have multiple files per `module` (because they are namespaces - not "software modules)).

### Tips: `Package`

- A package is probably what you should think of when you intend on developing a “software module”.

### Tips: `import MyPkg`/`using MyPkg`

- Yes, `import` or `using` is the thing to do if you import a separate package.
- When you `import MyPkg` (or `using MyPkg`), Julia first checks if it is already loaded.
- If not already loaded, Julia checks in its package “locations” (Project.toml+LOAD\_PATH folders), and loads it.
- `import MyPkg` (or `using MyPkg`) then returns a reference to the package’s associated module (i.e. namespace).

---

_[View the full topic](https://discourse.julialang.org/t/proper-way-of-organizing-code-into-subpackages/52835)._
