TORMIP哲研-27

Topics are as followed:
本文将围绕以下中心进行论述:

1.Tips for naming variables
   命名变量的小技巧

Let’s talk about the first topic: Tips for naming variables
先说第一个话题:变量命名技巧

In programming, a variable is a container (storage area) to hold data. Different programming langugages have different rules while naming varibles, but they have some similar features. We may sometimes ignore the importance of naming variables, which may cause some unexpected errors. So, in this article, I will give some tips in my personal view for naming variables.
在编程中,变量是保存数据的容器(存储区)。不同的编程语言在命名变量时有不同的规则,但它们有一些相似的特点。我们有时可能会忽略命名变量的重要性,这可能会导致一些意想不到的错误。所以,在这篇文章中,我将以我个人的观点给出一些关于变量命名的技巧。

Let’s imagine a scene. You are a programmer, yesterday you created a project, and today you want to improve the project, you want to delete or add some functions. However, when you are in work, you meet some unexpected errors, there too many varibables in this project, but you just named them casually yesterday, and it seems that you can’t understand the logic of the project you created yesterday. You begin reading codes in this project and try to find clear logic among variables again and again, but all in failure. That means, codes in your project can run normally, but you don’t know how these codes running. What a pity.
让我们想象一个场景。你是程序员,昨天你创建了一个项目,今天你想改进项目,你想删除或添加一些功能。但是,你在工作的时候,遇到了一些意想不到的错误,这个项目变量太多了,你昨天随便起个名字,好像看不懂昨天创建的项目的逻辑。你开始阅读这个项目中的代码,一次又一次地尝试在变量之间找到清晰的逻辑,但都失败了。也就是说,你项目中的代码可以正常运行,但是你不知道这些代码是怎么运行的。太遗憾了。

To avoid that consequence, naming variables in a logical way may be a good method. However, different people have different thinking methods when programming, it’s not easy to say whose logic right or wrong. But at least, we could have a not bad attitude towards variable naming.
为了避免这种后果,以逻辑方式命名变量可能是一个好方法。但是,不同的人在编程时有不同的思维方式,很难说谁的逻辑对错。但至少,我们可以对变量命名有一个不错的态度。

And of course, if other programmers try to maintenance your project, readable codes may be better for cooperation. When we speak natural languages in our lives, we hope others understand what we said, so we always try to orgnize words in a good way and then speak. Similarly, in programming, we may also care how to make other programmers easily understand our codes. “a,b,c, i, j, k…” may be a popular way in variable naming, but it’s not suitable in big project, cause it’s too abstract.
当然,如果其他程序员试图维护你的项目,可读的代码可能更适合合作。当我们在生活中说自然语言时,我们希望别人能理解我们所说的话,所以我们总是试图用好的方式组织单词然后说话。同样,在编程中,我们可能也会关心如何让其他程序员容易理解我们的代码。 “a,b,c, i, j, k…” 可能是变量命名的一种流行方式,但它不适合大型项目,因为它太抽象了。

Seems not easy to name variables, and we may have to put effort into it, yet worth it.
命名变量似乎并不容易,我们可能需要付出努力,但值得。

That’s all.
就这样。