# Best practice for managing package hierarchy

**URL:** <https://discourse.julialang.org/t/best-practice-for-managing-package-hierarchy/55822>\
**Category:** New to Julia\
**Tags:** package, module\
**Created:** [February 23, 2021, 5:23am UTC](https://discourse.julialang.org/t/best-practice-for-managing-package-hierarchy/55822 "2021-02-23T05:23:18Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![pbayer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pbayer/32/11675_2.png) [@pbayer](https://discourse.julialang.org/u/pbayer)\
**Post date:** [February 23, 2021, 7:53am UTC](https://discourse.julialang.org/t/best-practice-for-managing-package-hierarchy/55822/5 "2021-02-23T07:53:19Z")

</div>

ok, like you I would have

- `src/MyPackage.jl`, then

```julia
module MyPackage

abstract type AbstractA end

include("A.jl")
include("B.jl")
...

export AbstractA, my_func, my_other_func

end

```

- `src/A.jl` does not need to be another module, just gets included into `MyPackage`. Since` AbstractA` was declared **before** `A.jl` got included, you can use it:

```julia
# src/A.jl
function my_func(a::AbstractA) 
    # do something
end

```

- the same goes for `src/B.jl` (you don’t need another module):

```julia
# src/B.jl
function my_other_func(a::AbstractA)
    # do something else
end

```

If you write `include` above, the compiler sees `MyPackage.jl` like one larger source file, but you have the convenience to organise your functionality into several files. Just take care that types like your `AbstractA` are declared before being used in functions or other type declarations.

I usually have one source file like `types.jl` and `include` it first, where I declare common types, used by other source files `include`d after that. Thus I do not need to declare types in my main module file like `MyPackage.jl`.

Does that make more sense now for you?

---

_[View the full topic](https://discourse.julialang.org/t/best-practice-for-managing-package-hierarchy/55822)._
