-
Notifications
You must be signed in to change notification settings - Fork 34
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
Function declaration ordering #103
Comments
My preference is usually a topological sort, so functions below depend on functions above. I find this reduces the amount of jumping around the file I do while reading code as by the time I'm reading a function I will have encountered all the functions it calls. |
This is something which I've gone back and for on for quite some time, and still don't have an answer that I really like sadly. The few things that I've tried so far,
|
I've personally no strong opinions about the ordering, only that consistency within a file is good (don't have "helpers" both above and below the function that uses them, if you can help it, as that leads to the most jumping about). I think i tend to put the "main" function top, and helpers after. But perhaps a very small reason to favour the other way is that
|
@nickrobinson251 that may very well be how I picked up this habit, after working on AxisArrays |
Does anyone else wish we had a convention on ordering of functions in a file? I typically find putting private (more specific) functions further down in a file is more readable, but I don’t think that’s consistent. I also think some folks prefer the opposite to make copy-pasting into a REPL more intuitive? I suppose you could make the claim that they should just live in a different utilities file, but if they’re only used in that one file it’s kinda nice to keep them together...
The text was updated successfully, but these errors were encountered: