Tuesday, October 3, 2017

The Small Functions Debate In Computer Science

This blog post titled, Small Functions considered Harmful, by  Cindy Sridharan  addresses one of canonical principles in modern computer science - small functions.  As she points out below:

"The idea is simple — a function should only ever do one thing and do it well. On the face of it, this sounds like an extremely sound idea, in tune, even, with the Unix philosophy.

The bit where this gets murky is when this “one thing” needs to be defined. The “one thing” can be anything from a simple return statement to a conditional expression to a piece of mathematical computation to a network call. As it so happens, many a time this “one thing” means a single level abstraction of some (often business) logic."

This is a long blog post, but it is well written and for anyone who has written code, it challenges some of the principles.