35

Naming things

 3 years ago
source link: https://kodare.net/2020/07/26/naming-things.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

2020-07-26

We’ve been doing a lot of mob programming at work the last year or so and I’ve seen that I have a different attitude to naming things than others on my team. When I see that a name can be improved I always think this is priority number one. My colleagues often say “later”.

I also saw something related recently when doing a programming course internally at work. I sat and helped a guy with an issue he was having. I saw a really bad variable name and recommended he change it. He said “later, I just need to fix this first”. I pushed the point once more saying “trust me” and then left him to his devices. A few minutes later he asked for help again, being totally stuck. Renaming the variable got him immediately unstuck. He had wasted lots of time because the name put him in a mental trap.

My philosophy is: there are only two acceptable types of names: good names and metasyntactic names . If you have a name that is bad or just a bit misleading it’s better to rename it to foo NOW.

I believe good (or metasyntactic) names lead to easier problem solving and less effort in programming. It’s not just something we add at the end to make the code more understandable to others or future you. To me the primary thing we work with in programming isn’t numbers or computation, but language.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK