Writing Better Code Starts with Curiosity

Introduction

The idea of clean code has been around for at least 20 years. I learned about it when I began my career in software engineering. It is a school of thought that code is written for humans, not computers. Code is just written to make computers do stuff, and as we abstract away from machine code, it becomes easier to understand. Like all language, it can get cluttered and not communicate intent well.

Better Code

My idea of better code is just that, to write code better than we did the previous time. It is not that we are wrong, or that better code is right. It is that we can improve how we do things, anything, by practicing. And just like physicians, we can call what we do a “practice” in that we are trying to improve our ability and knowledge as we do the work.

Also, I want to state clearly that I believe in clean code and the practices and learnings that have been written about it. I love what Agile programmers have produced. I recommend reading books on the topic of Clean Code.

With “better code” defined, I want to establish some goals.

Begin

The goal of this site and article is to begin. I have been in the software industry for 20 years. I have worked on a variety of projects, from small to large. I have worked on a variety of languages, from C to Java to TypeScript to Python. I have had the privilege to work with many smart people. With all this said, I have seen things that work and do not work. I want to begin sharing what I have learned and provide a place to share what others have learned.

Curiosity

It begins with curiosity. Curiosity is the art of moving from where ever you start in an interaction and moving to asking questions. Whether you begin with judgment or disdain, you begin to learn and grow by moving to curiosity. When reading code it is good to ask questions in the realm of “what is the purpose?”, “why was this choice made?”, and “what is the impact of change?”. The goal of these questions is to not judge the answer, but to learn and seek more truth about the code.

“Why was this written like this?” I have worked on projects where I would see code or systems that I initially thought were just plain bad. I was young and thought I knew everything. It wasn’t that I was wrong, but I probably was, it was about that I had poor intentions to the questions I was asking. It was a matter of shifting my perspective with the same question. “Why was this written like this” shifts intention when looking for the history and reasoning behind a section of code. With that I was able to start being curious in the search of improvement, not about being right or better than others.

Keep moving forward

There is a great line from the Disney movie “Meet the Robinsons” that says “Keep moving forward.” It is about the ability to look at where you are, how you got there, and then move forward. We do not need to focus hard on any point in time, but understand what we need to and move forward.

So, with that in mind. Let’s start working on our curiosity and write better code.

Written by Pete Shepley