Clarity is hard

Published on 15 May 2014.

Today’s thought is about how I got stuck when refactoring a piece of code.

Yesterday I wanted to refactor a piece of code to make it more clear and easy to read. But I found myself stuck. The problem was not that I was afraid to afraid to break the code if I changed it. I had pretty good test coverage and felt confident that I could quickly verify a change. The problem was that I could not come up with a better way to write the code.

I know how the piece of code works because I wrote it, I did it quite recently, and it is not that long (maybe around 50 lines). But when I read it, it doesn’t immediately express the thoughts I had when I wrote it. It was frustrating to realize that I’ve not expressed my thoughts clear enough and at the same time not be able to do anything about it.

What can I do in situations like this? Some ideas:

Site proudly generated by Hakyll.