# Defining multiple modules in a package

**URL:** <https://discourse.julialang.org/t/defining-multiple-modules-in-a-package/52702>\
**Category:** General Usage\
**Tags:** package\
**Created:** [January 1, 2021, 6:35pm UTC](https://discourse.julialang.org/t/defining-multiple-modules-in-a-package/52702 "2021-01-01T18:35:11Z")\
**Posts on this page:** 1\
**Showing post:** 5

<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 1, 2021, 8:19pm UTC](https://discourse.julialang.org/t/defining-multiple-modules-in-a-package/52702/5 "2021-01-01T20:19:00Z")

</div>

### Step 3: no need for modules/namespaces

But my guess is that you never really wanted to create sub-modules d, e, & f.

Given that you were trying to do `using .d:f` from module A, my guess is that you really are just using separate files to break up your software into a more manageable solution:

Awesome; keep doing that 🙂 . It’s much easier to find code if you split up large solution into separate files.

But that means you can stick with a simpler structure:

A.jl

```julia-auto
module A
    include("d.jl")
    include("e.jl")
    include("f.jl")
end

```

Yup. That’s it. Now, all the code from d.jl, e.jl, and f.jl are now part of module A.

### very\_long\_function\_names\_to\_avoid\_name\_collisions

If you don’t need to split things into submodules - don’t. In julia, I find there is rarely a reason to do so.

In most languages, you need namespaces to avoid creating `very_long_function_names_to_avoid_name_collisions` - but that isn’t typically necessary in Julia.

### Leverage multiple dispatch

…instead of relying on namespaces.

If you want to create a method of `push!()` that behaves differently for your values, you simply create your own `struct MyType`, and define a special `Base.push!(::MyType, ...)` method - and it automatically plays nice with the rest of Julia. The same can be done with any other function.

---

_[View the full topic](https://discourse.julialang.org/t/defining-multiple-modules-in-a-package/52702)._
