Why You Should Start Using CUPID and Not SOLID To Write Maintainable Software
While SOLID has always been the standard, it can sometimes be difficult to always apply its principles, and according to Dan North, it may even be outdated.
Join the DZone community and get the full member experience.
Join For FreeSOLID is an acronym describing the principles of how to write maintainable software. Developed by Robert Martin, the five letters represent five design principles that would help make software designs easy to understand, flexible and scalable for when requirements call for changes.
While it has been the standard for software design and architecture for the last two decades, it can sometimes be difficult to always apply its principles. According to Daniel Terhorst-North, originator of Behaviour-Driven Development and Deliberate Discovery, SOLID may even be outdated.
“When Robert Martin was describing all these principles, he was collecting things. He wasn't just sitting there and making pronouncements. These are things that he'd seen in the wild and he thought they were useful things to bring together. So, there was a good intent behind it. But some things stand the test of time and some things don't, and in test-driven development - we're gonna talk about that later - I came across that over 20 years ago, it was decades old." he says during his interview at Coding Over Cocktails.
With North being an open critic of SOLID, he has come up with an alternative that calls for writing simple code. He calls it CUPID.
Write Simple Code
CUPID, North says, was conceptualized as he thought about the SOLID principles after a conference.
“So, for each of the five principles, I go 15 seconds describing it, 15 seconds describing why I don't like it, and 15 seconds saying what I would do instead and thinking, I would have exactly the answer to your question. And as I wrote the talk, I realized that the thing I would do instead was the same thing every time, which is write simple code,” he says.
In his interview below, he explains how he defines “simple code” and why it’s important that all developers understand what you’re trying to build.
“Simple code,” North explains, is not about the code that he alone understands but the code that “fits into someone else’s head.”
“My qualifications for that person's head is that they understand the language, the idiomatic code in that style of language. So, I'm not going to take someone who's never seen Go code before and say, ‘What does this do?’ So, the idea is that someone who's familiar with the language, its ecosystem, its core libraries, its run time, its build chain. And also, some familiarity with the domain that we're working in,” he says.
Being able to write simple code and being able to enjoy coding is what inspired him to come up with CUPID.
“I got to thinking about it and I ended up with properties. I said I wouldn't describe any principles as universal. They're all contextual, but there are properties of code that I think make it joyful to work with, that make coding fun,” North adds.
Learn more about SOLID and CUPID in this episode, and listen to more of the world’s leading experts on architecture, design, and the technologies that facilitate digital transformation on the Coding over Cocktails podcast.
Published at DZone with permission of David Brown. See the original article here.
Opinions expressed by DZone contributors are their own.
Comments