I get what you’re saying on short functions, but it’s tough to avoid mental gymnastics whether one is more strictly procedural or not. You’re either dealing w/ those nested IFs, or you’re jumping up and down to other functions to keep track of how the logic flows. I think it’s actually more of a personal preference than a best practice (totally IMHO). For me, I definitely prefer functions to do highly specific tasks, but I don’t mind larger chunks of code within them as long as they’re well commented. I use such helper functions usually only if I feel that they’ll be of use to me for other operations. If not, I don’t mind the logic being embedded in a longer function. Fortunately, I’m self-employed, so, I only have to cater to my own needs. I’ll be the first to admit that, in a team context, what you’re suggesting might well be a much better general practice. Nice piece! :-)

Written by

Web guy at ArrayWebDevelopment.com; author of books & blogs. See: JPDbooks.com.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store