Perfectionism and Fear of Writing Bad Code
The more I learn about programming and maths, the harder it becomes to write code. Experience and knowledge shows me all the things that could go wrong as a result of every line I add. Now days so much thought goes in the lines before I even touch my keyboard, that I find myself spending way more time thinking about writing code, than just writing code.
This is going to be a short post about what I have observed in myself. If you recognize this in yourself too, maybe it will help to shed some light on what it all means.
There is a good side. Professionally it helps me a lot. Specially for bigger projects that go over the scope of a few months. Projects I have to get right in a very specific way. From time to time, I would need to add a completely unexpected feature to the code base, and I feel proud of myself when I see that many months ago I spend the time and energy to set up the code in a way that would welcome the most chaotic changes.
There is also a bad side. I used to be able to write code and not worry about any of these. Finishing a product is like climbing a mountain. Having learned more about it, I now know how high it is. How much work it gets to get to the top. What can go wrong if you don’t choose your path up carefully. Before, in my ignorance, I would just start climbing it. Of course failing more often than not, learning in the process but also sometimes surprising myself and making something of value. Now I feel overwhelmed from all the things I need to keep in mind to make sure the code is “good” that I end up not attempting it at all. After all I am probably never going to make it to the top.
A few days ago I had a problem to solve. I won’t bore you with the specifics of the problem. Before really trying to solve it I spend an hour assessing the problem. After that hour I just stopped. Because I realized the problem has a way more complicated underlying analytical principles than I thought. What seemed to be a simple linear system was in reality a system of differential equations. I didn’t even attempt to solve the problem and moved around it. If this was a few years ago, I would have not known any of these, and I would have just tried it.
I think there is value in attempting to solve problems you would probably not solve, so I started thinking about how to make this constrain go away. Around the beginning of last year, I was feeling pressured by all these thoughts. I had a harder time actually finishing hobby projects. I would start with the project, get lost in thinking about the code I was writing, get overwhelmed by the huge amount of work that still needed to go in and get distracted by the next new shinny idea.
I recognized this to be a problem of perfectionism in me. Why does it matter if the code is not perfect? Can I not create value if I don’t get to the summit of the mountain? Can I not make things that create tangible values that have memory leaks, bad performance, bugs and don’t work on every environment?
I decided to force myself to come in terms with it. I started writing code that I would share with others on Github. The codes were full of mistakes, full of potentials for optimization and sometimes they wouldn’t even get anywhere. I would get comments from colleagues, friends and strangers, telling me about how the memory allocation is not perfect or performance could be better.
But I also learned a lot. Some of the problems actually happened to be solvable. Some not to the end but I mapped out as far as I could, and other people picked it up. Also it turns out that you can still create value for other people by doing only part of the work. People would get in touch and thank me for specific things I helped them with without even knowing. Every single one of those made me happy.
So in summary, writing shit code is a skill I am trying to develop. What has helped me so far was to write incomplete systems, share it with other people and see what happens. If you have a similar issue, maybe try it out too.