In poetry class I learned that performing inside a straight jacket can, surprisingly, work out pretty well. Drawing with a peculiar pen, working in an unusual medium, or venue … all these can work out surprisingly well. You can go too far though. Knowing that an abundance of choice does not make us happy is not an argument for eliminating all choice.
“Moderation in all things” is how Patrick Stein sums up a post on trying on a few programming straight jackets. No function over five lines. No package (we are talking Common Lisp here) spread over multiple files. Unusual coding conventions for your package namespaces. He is having fun.
Seems to me that a rule on the maximum size of a function is silly. Surely the question is what is the right distribution of function sizes – i doubt it’s normally distributed. I’d think a good rule might be that a function’s size should signal something about it’s complexity. Isn’t function complexity mostly independent of program modularity? I.e., modularity alone can cause functions to fragment. It is a common fetish: “small is beautiful.” And, that helps to explain why I’ve never heard people advocating against small functions. I’ve often encountered code that seems scattered into a thousand tiny pieces, it becomes incomprehensible. That is certainly the wrong thing to do, except when it isn’t.
I’ve seen this practice of asceticism in coding show up in the Unix shell, of all places. The habit there is of keeping your ~/bin/ directory well-stocked with simple commands that you do repeatedly and that can be piped together into more complex commands. The ugly shell constructions and weird regular expressions are hidden away so you don’t have to remember them again.