Any large and complex creative endeavor needs a design. A movie needs a script and story boards. A novel needs a theme, a premise and a plot outline. A work of art needs composition.
Producing software is no different. Good computer code isn’t just written. It’s designed. Good code needs a theme, an overall structure and a clear point and purpose, not unlike a good novel or a good movie.
So what makes code good? The lowest bar code needs to meet is that solves the problem it was written to solve. That’s like saying a movie has a plot climax. Just because we’ve cut to the chase doesn’t mean it’s a good movie. Just because the code solves the problem doesn’t mean it’s good code.
That’s where the concept of “clean code” comes in. A clean design is simple, effective and elegant. Consider the difference between one of first smart phones—now lost to the dustbin of history—and the first iPhone:
These two products did the same thing. But one of them had a more elegant design—a cleaner design—and has thus become the most popular smart phone in history, despite its greater cost.
So clean code is effective in that it solves the specified problem. It’s simple in that it’s easy to understand. It’s elegant in that all that is in the design of the code is what’s necessary, nothing less, nothing more. Kind of like the design of the iPhone. More on this here: Clean Code