Two popular, but conflicting programming styles: Small functions vs deep...


Two popular, but conflicting programming styles:

Small functions vs deep functions.

The book “Clean Code” argues for small functions: “The first rule for functions is they should be small. The second rule of functions is that they should be smaller than that. Functions should do one thing. They should do it well. They should do it only.”

In contrast, the book “A Philosophy of Software Design” argues for deep functions: “Length by itself is rarely a good reason to split a method. Splitting a method introduces additional interfaces which increases complexity. It also separates the pieces of the original method which makes the code harder to read if the pieces are actually related. Split based on complexity. Each method should do one thing and do it completely.”

Which style do you prefer, and why?
This is perhaps the most fundamental fight in software.

Some feel small functions aid readability and comprehension. Others feel they add complexity and slow comprehension.

I prefer small functions, but I also recognize they’re a tradeoff.

View original on X