How should I organize functions in a module?

So inside of my module, I have functions that aren’t supposed to be called from outside the module, only ran from functions that are inside the module. How should I organize these functions? Should they be at the top of the module before any other functions, or inside the module functions they are being called in?

Sorry if that sounds confusing. I tried my best to explain it. Any replies are appreciated!

In a separate table & have the module return a table containing two tables, one of those tables being functions to be used normally & the other table containing functions which are to be used in the way that you described, also alphabetically arranging functions is always a nice touch.

I don’t think you quite understand what I mean. I don’t blame you. I probably explained it poorly. Let’s say this is inside of a module script.


Where should I locate that function that is circled in red? Inside the function, at the top of the script, or somewhere else?

If it’s returning a value/values that are required then whenever those values are needed? I’m not sure I understand what you’re trying to ask.

It’s a stylistic thing. To me, any function that is used should be declared before another function that calls it.

My current etiquette in writing modules goes like this:

  1. Require services
  2. Require other modules
  3. Constants
  4. Variables
  5. General use functions within that individual module
  6. Actual module code
3 Likes

You could make another module if those functions are too big.

1 Like

Ok, thank you! I think I’ll use this method.