2023-W11 Wendland Weekly

This week, I went skiing in Austria with some friends. We had a lot of fun, and I even got some time to read a bit of Clean Code by Martin C. Robert. I made it up to the end of Chapter 2 (which is about naming conventions) and, based on what I learned, as well as a video by Code Aesthetic on naming variables, I decided to write a note about Naming conventions. However, I found myself in a bit of an argument with ChatGPT about whether or not to include the types in variable names. You can find a summary of my thoughts in the Don’t include the type in the name section.

The main issue I’m grappling with is that I work with Data, but I also want to improve my Programming Index skills. From a programming perspective, I think it’s completely unnecessary to include the type in the name of a variable. If you feel like you need to do this for clarity, it’s probably a sign that your function or class is too long. Even if it’s difficult to shorten your code, your IDE should be able to help, and the name of the variable should be clear enough.

However, from a Data perspective, things are a bit less clear-cut. When exploring a dataset, it’s common to write scripts quickly and loosely, piecing things together to see what’s there. (In other words, you’re maximizing velocity on the velocity-adaptability-performance triangle, as described in the Code Aesthetic video on Premature Optimisation.) In this context, it can be helpful to include the type in variable names as a quick reminder of what type of data is being used. For example, you might include “datetime” in the name of a variable to remind yourself that it’s a datetime object, rather than a Unix timestamp. However, maybe these concerns only arise because of an internal lack of consistency.

In conclusion, I’m still a bit confused about whether or not to include types in variable names. I often find myself in this kind of situation where I feel like things would be easier if I were better at programming! … I’ll most probably try to avoid including types in the names knowing it is the right thing and hate myself every time I inevitably do do it.