I have been writing a lot of Ruby code lately. This is because I’m rewriting Airtyper’s entire backend with Ruby on Rails.
Given Ruby’s clear and plain English like syntax, same for Rails, it somehow feels terrible to write code that’s not elegant.
I mean, sure, I can throw in some code to get a feature working, but every time I write code in Ruby, I ask myself:
“Is this how a Ruby enthusiast would write this functionality?”
A lot of times, the answer’s no.
At those times, I revisit the code that I wrote and try to make it cleaner and more concise. Refactor it to something that carries the Ruby flag: read like the English language.
What this has taught me is that this philosophy is not only applicable to programming. Almost everything can be and should be simplified.
Imagine writing an article. Are you ever satisfied with your first draft?
Or that painting; is your first stroke always the last one?
In most cases, the answer is no. A craftsman always polishes to get the best version out of his work.
Polishes to make the work understandable and straightforward.
Simplicity always wins. If you create something that requires someone to read a manual first to understand then it’s not your best work.
Do better. The goal is to make everything readable or rather easily understandable.
Doesn’t matter if you’re writing code or an essay or maybe creating a tangible product. Keep revising until you’re absolutely convinced that the end product is damn elegant.