# How to structure a mid-sized OOP-like project physically and logically - Types.jl, Submodules or "deep Hierarchies"?

**URL:** <https://discourse.julialang.org/t/how-to-structure-a-mid-sized-oop-like-project-physically-and-logically-types-jl-submodules-or-deep-hierarchies/40410>\
**Category:** General Usage\
**Tags:** question, module\
**Created:** [May 29, 2020, 10:13am UTC](https://discourse.julialang.org/t/how-to-structure-a-mid-sized-oop-like-project-physically-and-logically-types-jl-submodules-or-deep-hierarchies/40410 "2020-05-29T10:13:38Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![virtualgraham](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/virtualgraham/32/15200_2.png) [@virtualgraham](https://discourse.julialang.org/u/virtualgraham)\
**Post date:** [May 29, 2020, 12:32pm UTC](https://discourse.julialang.org/t/how-to-structure-a-mid-sized-oop-like-project-physically-and-logically-types-jl-submodules-or-deep-hierarchies/40410/2 "2020-05-29T12:32:27Z")

</div>

Julia developers typically do not structure code to follow classic OOP design patterns. Julia does not have interfaces or property inheritance which most of these patterns rely upon. Instead Julia leverages principals such as dynamic dispatch and composition. See [Composition and inheritance: the Julian way](https://discourse.julialang.org/t/composition-and-inheritance-the-julian-way/11231). Also, in regards to the code you have so far, while you are free to structure the code however you want and I think the way you have divided up the code into multiple files is fine, but generally I would try to avoid using sub-modules as much as possible. Ideally there would be one main module for your package. Im not sure why the linter would not work with just one module.

Edit: Here are some other threads on this topic

> [@Classes in Julia](https://discourse.julialang.org/t/classes-in-julia/24521/9):
>
> Take for example this python code, how can you translate to Julia class Employee: empCount = 0 def init(self, name, salary): self.name = name self.salary = salary Employee.empCount += 1 def displayCount(self): print(“Total Employee %d” % Employee.empCount) def displayEmployee(self): print("Name : ", self.name, ", Salary: ", self.salary) emp1 = Employee(“Zara”, 2000) emp2 = Employee(“Manni”, 5000) emp1.displayEmployee() emp2.displayEmployee() print(“Total Employee %d” % Employee.e…

> [@Julia OOP example](https://discourse.julialang.org/t/julia-oop-example/27568):
>
> I am a C++ and Python user and quite accustomed to OOP for some tasks. The following is a small example of using OOP style in Julia. Please give comments if there are better ways to do that. Thank! Hope it could help the users have the similar demand. # animal.jl abstract type AbstractAnimal end mutable struct BaseAnimal name::String weight::Float64 BaseAnimal() = new("", 1.) end function get\_weight( animal::AbstractAnimal ) return animal.base.weight #no member varia…

---

_[View the full topic](https://discourse.julialang.org/t/how-to-structure-a-mid-sized-oop-like-project-physically-and-logically-types-jl-submodules-or-deep-hierarchies/40410)._
