"Magic is just science that we don't understand yet" — Arthur C. Clarke


The more correct functions in your program, the less bugs.

Consider this: if your program were made solely of functions that provided the correct output for any given input. Then by definition your program would be correct for any given input. So, if you can minimize the amount of functions that output values that are “sometimes correct”, you can minimize the amount of bugs in your software.

Relevant XKCD explains why SRP (Single Responsibility Principle) matters.

XKCD Workflow

To me, this comic illustrates exactly why SRP is such an important principle. You can with certainty guarantee that someone (probably yourself) will take advantage of a functions side-effect. Once this happens it is a pervasive invasive epidemic which infects your entire program. It makes it extremely difficult to remove that functionality, and refactor. Because the moment you remove it, now you’ve got a function asking you to re-enable the spacebar heating thing, and that functions callers asking why they no longer see the behaviour, and on and on.

Leave a comment