Michelangelo's Guide to Refactoring Code
By Michael Renken
A quote of Michelangelo’s has always stuck in my head
In every block of marble I see a statue as plain as though it stood before me, shaped and perfect in attitude and action. I have only to hew away the rough walls that imprison the lovely apparition to reveal it to the other eyes as mine see it.1
Does a perfect solution exist for every problem, and we just need to open our eyes to it?
I can’t say that I always see the perfect solution before I start working on a new service or a new feature. But I do know that, as I live with an imperfect system, I start to see how things can be improved. I wonder if the visionary simply exagerated his abilities because he knew he was channeling something divine and the end result would be the same regardless? He was definitely known to hold his own art and process in high esteem2.
For our thought experiment, let’s start with a slab of marble. Under Michelangelo’s philosophy, there exists two types of matter - what shouldn’t be there and what should be there. Quite simply, if you slowly chip away at what shouldn’t be, you’ll eventually arrive at what should.
I can imagine slowly revealing a rough head on some rough shoulders. If the arm is outstretched like this, where would the head be facing? Should the eyes be open - alert. Or half-closed to convey pensiveness or another emotion?
Like a sculpture, systems created by software interact with a living world. We observe its interactions like you would observe light bouncing off a cheek or how the human gaze travels from the wall to a particularly chiseled buttock. But how do we know what should be and what shouldn’t?
As David Hume philosophized, you cannot derive an “ought” from an “is”3. That is, you cannot scientifically calculate a perfect solution without an imperfect, rigid set of rules to base this system on. So, how then do we determine the proper solution? In my estimation, you really just have to feel for it.
“What would this look like over there?” “How about if we separate these two bits of logic?” “This might be a little confusing for someone who might have to debug this problem further in the future.” And if you really want to channel the divine as well as Michelangelo, you might just have to get down on your knees and pray.
-
Michelangelo - https://www.azquotes.com/quote/574899 ↩︎
-
Unger, Miles J. “A Life in Six Masterpieces” (2014) Exerpt: https://dianerehm.org/shows/2014-07-24/miles-j-unger-michelangelo-life-six-masterpieces ↩︎
-
Jenkins, Scotty - David Hume and Deriving an “Ought” from an “Is” (2017) https://theought.com/2017/07/10/david-hume-and-deriving-an-ought-from-an-is/ ↩︎