Blogging is my new favourite refactoring tool
I've mentioned a few times in talks and social media before but while writing my blog post on Netlify Functions, I was again reminded by it so I decided to write a full blog post on the topic.
Blogging is my new favourite refactoring tool.
It's a bit exaggerated statement but for my use case, it works exactly like that. I don't write code full-time professionally anymore but I still code: I build software and scripts for myself, for events or online activities I run and sometimes for non-profit organizations. And since my methods of communicating, sharing and teaching tech related concepts is through blog posts, workshops and talks, I tend to write a lot about what I've built. Sometimes directly, sometimes indirectly.
During 2021, I've written a series of blog posts about my learning journey with Rust (start here) and I've used examples from the command-line tool I've been building.
When I write code, my mind prioritizes function over form. Essentially, I'm trying to write code that works and does a job. I then refactor it to be better but I'm still often in the development mindset and don't notice everything.
When I write a blog post, I'm focusing on explaining things to others. When I then pick up an example from my code, I often see things I didn't see before. Many times I've written "this could have been done better by X", only to realize I should just refactor that into the code directly and showcase that in the blog post.
I read my code very differently when I'm in the development mindset compared to the blogger mindset. I do a bit of extra research on the topics when I write about them so I'm learning new things to apply but I also look at the code in an isolation.
When I was writing my blog post on Netlify Functions, I realized that instead of fetching the data on each click, I can just fetch it once during page load and run filters over it. It makes sense but I was so deep in the "can I learn how to make it work" pit that I didn't even think about it until I started explaining to readers what I did.
This extra learning and refactoring that happens is one of the reasons I think that You should start a blog today. It even works if you never publish those blog posts to the public because the value is created during the writing and editing process.
And when you do start your blog, make an RSS feed available so people can subscribe to your blog and you don't have to rely on cutting through the noise of social media feeds and their algorithms.
Sign up for Syntax Error, a monthly newsletter that helps developers turn a stressful debugging situation into a joyful exploration.
If you found this post interesting, consider sharing it with your community or following me on Mastodon.