Refactoring, Roman Numerals, and a Shift in Perspective

Looking at something from a different point of view can reveal a hidden side, says Kevlin Henney in a recent essay on paradigm shifts, refactoring, and Roman numerals. 

This hidden side can be physical, Henney says, or more abstract, as in the case of software architecture where view models “can be used to bring different concerns of a system into focus.” 

Numeral systems have a similar quality, he says: “Changing how numbers are represented doesn’t change the numbers represented, but it does change how we think about them. Thinking about integers in binary, for example, reveals different patterns (and failures) than when we think about them in decimal. Binary also chunks more easily into hexadecimal. Thinking about RGB triplets makes more sense in hex than in decimal. And so on.”

In the far-ranging article, Henney works through several refactoring steps using a sample of Python code that converts a number to a corresponding string of Roman numerals. In examining the code, Henney explains that “recurrent structure is often a good starting point for seeing what can be abstracted.” And, he notes, “the rhythmic stanza of a while followed by three if statements looks like a good fulcrum from which to lever a refactoring."

“The value of paradigms, perspectives and points of view is in their multiplicity," Henney says. “Sometimes one offers a better frame for understanding or creation than another...” And “sometimes, like binocular vision, we need more than one to make sense of a situation or to unlock a solution.”

Read the complete article on Medium.

Comments