Lately, for reasons which slip my mind right now, I had to review some old library code I wrote. And as always when you review code you wrote a while ago, you think “How could I have ever thought this was good code?” Usually this is because the code contains more hacks than clean code or because you can’t even understand what that piece of code does. In this case I was quite ok with that, but could have hit myself hard for not recognising a general pattern of all distinct cases I programmed back then. This prompted me to go to:
- Rewrite the code in the more general way, reducing the code size by 30% and increasing the speed on two cases and
- Go into research mode for finding even better patterns of generalisation.
I can’t really show you the difference in 1. because I wrote the code for a project I was hired for and it’s not really open source but I decided to make a series of blog post about 2. I hope you like it.