This month I want to highlight an article, The Wrong Abstraction, by Sandi Metz. This article discusses the long-term effects of augmenting your abstractions, removing the initial tightness of the abstraction to accommodate one-off behaviors. Your code, once clean and concise, become fragile and error-prone. The author advocates for removing the abstraction to understand the requirements under which the code now operates. Then, with no preconceived notion of a previous abstraction, abstract as appropriate
We should not write code that assumes future, unstated requirements, and we should remain open to refactoring code as new requirements emerge. By doing so, we retain our ability to move fast over the long term, and not become overwhelmed with fragile code.
https://sandimetz.com/blog/2016/1/20/the-wrong-abstraction
“Existing code exerts a powerful influence. Its very presence argues that it is both correct and necessary. We know that code represents effort expended, and we are very motivated to preserve the value of this effort. And, unfortunately, the sad truth is that the more complicated and incomprehensible the code, i.e. the deeper the investment in creating it, the more we feel pressure to retain it…”
Leave a comment