So I am not sure there are cannonical answers to some of these questions,
but I'll try to address some of them based of my current opininions. So
imho, and fwiw etc...
1. Major Calculations should mostly be a package. A package is not
necessarily a library, it is a self contained unit of code sharing. So if
you want to share your code publicly, it should most certainly be a
package. If its only a private piece of code, private to you or your
organisation, then you can get away with not making it a package. However,
I think you would benefit from making it one, if only for the reason that
the src/ directory of all packages are automatically in the load path.
2. I think this is a personal choice based on your domain and design.
Creating separate modules will create clear boundaries between parts of
your code. Only you can decide if that is valuable to you.
3. If you make this a package, then your main file should be
MajorCalculations.jl . This file will be loaded when calling "using
MajorCalculations" . Beyond that, your are free to layout your code as you
wish. The majority of Julia packages these days I think have functionality
in separate files (and optionally separate modules) that are "included" in
the main file for the package
In terms of steps, I believe you should model your steps as function calls.
So one way would be
#file: MajorCalculations.jl
module MajorCalculations
include("first.jl") #define function first()
include("second.jl") #define function second()
function process()
first()
second()
end #function
end #process
4. Yes, putting constants in global scope is fine. I believe there will
not be a performance issue is you mark the variables as "const"
5. If the functions have different number of types of parameters, they will
not clash, they will be multiple methods of a single function (so long as
correcly imported). If they really clash, then don't export them from the
module, call them with a fully qualified name "Module.func()"
On Monday, 23 February 2015 14:39:49 UTC, Marc Gallant wrote:
>
> I'm having some trouble figuring out the proper way to organize a project
> in Julia. I understand how a *package* is organized (from the many
> available examples), but now I am writing code that uses various packages
> (my own and others) and I don't feel like I have a good idea on how a
> *project* should be organized.
>
> Let's say I have a project called Major Calculations that uses the
> packages Foo.jl, Bar.jl, and Important.jl.
>
> 1. Should I use Pkg.generate() to create Major Calculations? In other
> words, should it be a package (in the julia sense)? It isn't going to be a
> library of types and methods, but rather a project where I give it large
> amounts of data and it outputs modified data and plots.
>
> 2. Should I break down Major Calculations into separate modules? For
> example, there are groups of functions that are related. Should each of
> these get their own module?
>
> 3. What should the directory layout of Major Calculations be? Should I
> have a main.jl? What if I want to process the data in steps (e.g.,
> first.jl, second.jl, ...).
>
> 4. When I use the project, I want to pass it two files: a configuration
> file, and the data file. The configuration file will define a bunch of
> constants that are used throughout Major Calculations (i.e., it is
> required). Should these be declared as global consts? If that's the case,
> should I have a file (e.g., constants.jl) that I include at the start of
> main.jl that reads the file and just sets all constants? And should this be
> completely in the global scope?
>
> 5. If the two modules Foo and Bar both export functions with the same name
> (but different parameters), how do I avoid conflicts? Should the project
> use "import" instead of "using"?
>
> In essence, I am just having a hard time differentiating how code is
> organized when it is a package for general usage, compared to how it
> organized when it is a project used to process data.
>
> Thanks for your time.
>