This content originally appeared on Go Make Things and was authored by Go Make Things
When it comes to writing functions, there are two extremes:
- One really big function that does all the things.
- Lots of really small functions that do just a single thing.
In my experience, beginners tend to write really big functions, while more seasoned devs tend to break stuff up into lots of really small “pure” functions.
While I think smaller, more narrowly focused functions are better for readability and maintaining code, it can also lead to code bases that are big nested dolls of functions calling functions that call other functions that call more functions.
That kind of setup is in many ways harder to read and maintain than one really big function (and it’s worse for performance, too).
I use three basic guidelines for when to break parts of a function into separate, smaller functions…
- Is it getting hard to read?
- Is it hard to name because it does too much stuff?
- Does any of the same functionality get used elsewhere?
If the answer to any of those is “yes,” it’s time to split at least some of the function into its own separate thing.
If not, it’s probably ok to keep it where it is.
Like this? A Lean Web Club membership is the best way to support my work and help me create more free content.
This content originally appeared on Go Make Things and was authored by Go Make Things

Go Make Things | Sciencx (2025-01-17T14:30:00+00:00) How to structure functions. Retrieved from https://www.scien.cx/2025/01/17/how-to-structure-functions/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.