How to structure project in julia

Sorry, late for the discussion, but let me give my two cents:

The best option is a mix of options 2 and 4, which by themselves are not really options I see someone considering.

A submodule should only be included where it appears in the hierarchy for an external user. If a package Graphs.jl has Graphs.Algorithms then Algorithms.jl should be included inside Graphs.jl, if it is Graphs.Utilities.Algorithms then then Algorithms.jl should be included inside Utilities.jl which is included inside Graphs.jl. In other words, include should be only used to build the unique hierarchy of the modules in the project, it is not a tool to load code that will just be called. What however, if Graphs.Experimental.Search needs to use some methods from Graphs.Utilities.Algorithms? Simple, in Search.jl you do:

import ...Utilities.Algorithms

See Modules · The Julia Language about the relative import syntax.

I structured a rather large package with all my code from my PhD following this system. Here is the main file: https://github.com/henriquebecker91/GuillotineModels.jl/blob/master/src/GuillotineModels.jl and here is the file of GuillotineModels.PPG2KP: https://github.com/henriquebecker91/GuillotineModels.jl/blob/master/src/PPG2KP/PPG2KP.jl Note that I did also started a new subfolder for each submodule that had submodules themselves to avoid clashes like two Algorithm.jl in a Graphs.Utilities.Algorithms and a Graphs.Experimental.Algorithms.

12 Likes