Naming things

栏目: IT技术 · 发布时间: 5年前

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.


以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

51单片机应用从零开始

51单片机应用从零开始

杨欣、王玉凤、刘湘黔 / 清华大学 / 2008-1 / 39.80元

《51单片机应用与实践丛书•51单片机应用从零开始》在分析初学者认知规律的基础上,结合国内重点大学一线教师的教学经验以及借鉴国外经典教材的写作手法,对51单片机的应用基础知识进行系统而翔实的介绍。读者学习每一章之后,"实例点拨"环节除了可以巩固所学的内容外,还开辟了单片机应用的视野;再加上"器件介绍"环节,又充实了对单片机从基础到应用所需要的知识。8051单片机不仅是国内用得最多的单片机之一,同时......一起来看看 《51单片机应用从零开始》 这本书的介绍吧!

在线进制转换器
在线进制转换器

各进制数互转换器

UNIX 时间戳转换
UNIX 时间戳转换

UNIX 时间戳转换

HEX CMYK 转换工具
HEX CMYK 转换工具

HEX CMYK 互转工具