# Single module vs. submodules in a project

**URL:** <https://discourse.julialang.org/t/single-module-vs-submodules-in-a-project/55361>\
**Category:** New to Julia\
**Tags:** performance, modules, code-organization\
**Created:** [February 15, 2021, 11:23pm UTC](https://discourse.julialang.org/t/single-module-vs-submodules-in-a-project/55361 "2021-02-15T23:23:33Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

**Author:** ![jebej](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jebej/32/1784_2.png) [@jebej](https://discourse.julialang.org/u/jebej)\
**Post date:** [February 16, 2021, 7:29pm UTC](https://discourse.julialang.org/t/single-module-vs-submodules-in-a-project/55361/8 "2021-02-16T19:29:26Z")

</div>

You are not using submodules here, you are just creating two individual “packages”, though because you are pushing to `LOAD_PATH` these things are less clear.

A submodule must be defined within the scope of a parent module, like in the example [here](https://MySubModule) copied below, or by `includ`ing the file containing the submodule within the parent module. The module blocks must be nested.

```julia
module Parent

module Utils
...
end

using .Utils

...
end

```

If you want to do that precompilation test properly with submodules, you would need the following:

```julia
module MyModule # MyModule.jl 

include("MySubModule.jl")
using .MySubModule # note the dot

export f

f(a) = 2*g(a)

end

```

As a side note, pushing to the `LOAD_PATH` is not the best way of organizing code, since you won’t be making use of dependency resolution and reproducible environments you can do with a `Project.toml` file and using `Pkg`.

---

_[View the full topic](https://discourse.julialang.org/t/single-module-vs-submodules-in-a-project/55361)._
