It is interesting to look at code not only from the content aspect, but also from the appearance. The appearance of code can give hints how to refactor it.
Beyond the mere visual aspect of code, the shape of a piece of code can carry information by itself. Being able to decipher this information allows to glean indications about the code at a glance, even before starting to read it.
When I write code, it often serves the purpose it is supposed to serve. However, it is often not the most elegant. Especially when I compare my code with other implementations, I sometimes find mine somewhat ugly. I think I’m thinking too chaotic, start writing the code immediately and while I’m writing it, I think of things I could do differently and in the end it’s a big mess. Maybe I should first sketch my code on paper and then type it into the computer without thinking much about it?
I wrote about my Indieweb dream this morning. To come closer to this dream and to clean up some code, I started refactoring my hugo backend code. I made use of Go interfaces to later be able to easily add more storage, CDN or social network providers. It also made the code a bit cleaner and a bit more modular, but there’s still a lot of learning and work to do.