I don't always write the best code. I write code that runs, passes tests, and solves the business problem. Unfortunately this also means it's often code I come back to in a month or so and want to scrap to completely rewrite.
That said, I never want to refactor code just for the sake of refactoring code.
I want to rewrite my code because it's ugly. It's not poetry. It's not art. It's not even worthy of being used as an example slide in a presentation or a blurry screenshot in an article. It's that code you use as an example of what not to do.
And it ships in finished products.
The Battle Between Beauty and Shipability
Sometimes we have to make the tough call and label code as "good enough" so we can get it out the door. This is a necessary evil of shipping a final project, but it also sacrifices inspiration and innovation. Beautiful code, like any form of beautiful art, takes time to develop and get right.
I once met a poet who spent a year writing a 15-line poem. A year.
I asked why it took so long. "It didn't feel right."
His job wasn't just to write fifteen lines of text. It wasn't to fill the page with words that looked nice together. His job was to convey human emotion - to paint a picture with symbols and images that felt universal and personalized at the same time.
He did an effective job, and that tiny poem won him plenty of awards over the length of his career. It actually paid, in the end, far more than any fifteen lines of text have ever come close to paying in mine.
We constantly walk the line between writing code that ships or functions and code we can be proud of. It feels a bit disingenuous to say we're on the verge of "software craftsmanship" when I have yet to meet a developer who hasn't apologized for the state of their code before letting a colleague take a look at it.
A carpenter doesn't apologize for their table before showing it off to a customer. A painter doesn't apologize for their landscape before a showing. A writer doesn't apologize for the poor diction in their novel on the inside of dust jacket.
We shouldn't be apologizing for our code before showing it off. We should be focusing on making our code both functional and something to be proud of. We should focus on shipping not at the expense of beauty in our code, but because we've built beautiful code.
Blaise Pascal has been quoted as once saying, "I would have written a shorter letter, but I did not have the time." Writing a short, elegant, beautiful letter takes time. But the letters given that time are treasured for generations.
Writing short, concise, beautiful code takes time. One day, though, we might actually write code that will likewise be treasured.