-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Minor improvements and best practices #8
Comments
The files that you use to make plots could be converted into Pluto notebooks or Jupyter notebooks. This is optional, but I recommend it because notebooks are good for interactive visualization. |
A good practice is to try to divide your code into functions, rather than writing long scripts. In notebooks it is perfectly fine to write scripts, though. In a notebook you should only write functions in case you find yourself repeating the same lines of code over and over, but then those functions should be placed in a separate file, and imported by the notebook. |
For better performance, use const for global variables that do not change. If its value changes during execution, but the type remains the same, then you can provide the type for better performance (this is only available from julia 1.8): x:Int64 = 4 |
Standard desviation should be written without the s (deviation). |
It is better to write all the paths on top of the file. This way, with a quick look at the file, you already know what data it is importing. |
Be more explicit with variable names. Write this: # Define paths
data_dir = joinpath(@__DIR__, "..", "data")
grid_path = joinpath(data_dir, "grid.jld2") instead of this: #Define the path of the data files
path = joinpath(@__DIR__, "..", "data")
#Load the grid
file=joinpath(path,"grid.jld2") |
Use JuliaFormatter.jl to autoformat your code. It formats your code so that it follows the preferred julia coding style. Install this package in the global environment, rather than in the project environment, because we don't want this package in the Project.toml file. You can do this by running this in the terminal: julia using Pkg
Pkg.add(JuliaFormatter)
using JuliaFormatter And then, from the format(".") This will fix all format issues in your files. You can see all changes in a particular file by pressing git diff plots2d.jl Try to see what it has corrected, to avoid repeating the same mistakes in the code you write from now on. |
File names should be written in lower case, unless they are modules. |
Fixed, thanks for the advise |
Hi @Victor-Garcia-p
Here I will write some improvements that could be done in the code.
The text was updated successfully, but these errors were encountered: