Code style: Main functions on top, small functions on bottom or vice-versa?

When programming a module in Elixir, I like to start my module with one or two ‘main’ functions that show the main flow of data that will go on in here, and then write out the ‘small’ functions that are used internally in there.

I find this to be very readable, and giving future readers the opportunity to first see the problem from afar, and then zoom in to the part where you think something might need to be changed or updated.

Now I’ve seen multiple people writing modules in the opposite fashion, with the smallest (often private) functions on top, and the main functions at the bottom. I personally find it less nice to read, but are there any advantages of this approach?

1 Like