小写驼峰变量大小写约定(例如thisVariable)的意义是什么? [英] What is the point of the lower camel case variable casing convention (thisVariable, for example)?

查看:120
本文介绍了小写驼峰变量大小写约定(例如thisVariable)的意义是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望不会因为范围太广而被关闭.我知道这取决于个人喜好,但是所有大小写惯例都有一个渊源,我想知道该惯例来自何处,以及人们为什么使用它的合乎逻辑的解释.

I hope this doesn't get closed due to being too broad. I know it comes down to personal preference, but there is an origin to all casing conventions and I would like to know where this one came from and a logical explanation as to why people use it.

就像var empName;一样,在这里.我叫那只较低的骆驼,尽管在技术上可能叫别的东西.就个人而言,我喜欢var EmpName.我叫那头合适的骆驼,我喜欢它.

It's where you go all like var empName;. I call that lower camel, although it's probably technically called something else. Personally, I go like var EmpName. I call that proper camel and I like it.

当我第一次开始编程时,我从较低的骆驼约定开始.我不知道为什么我只是遵循了所有老家伙树立的榜样.变量和函数(VB)具有较低的骆驼,而子级和属性具有适当的骆驼.然后,在我最终对编程本身有了一个牢固的掌握之后,我变得足够自在地去质疑导师的策略.使用低级骆驼对我来说没有逻辑上的意义,因为它不一致,特别是如果您有一个包含一个单词的变量,而该单词最终都变成小写的话.也没有适当的验证机制来确保您适当地使用低级骆驼还是上级骆驼,所以我问为什么不对所有事物都使用适当的骆驼.这是一致的,因为所有变量名都经过适当的修饰.

When I first started programming, I began with the lower camel convention. I didn't know why. I just followed the examples set by all the old guys. Variables and functions (VB) got lower camel while subs and properties got proper camel. Then, after I finally acquired a firm grasp on programming itself, I became comfortable enough to question the tactics of my mentors. It didn't make logical sense to me to use lower camel because it wasn't consistent, especially if you have a variable that consists of one word which ends up being in all lowercase. There is also no validation mechanism in place to make sure you are appropriately using lower vs. upper camel, so I asked why not just use proper camel for everything. It's consistent since all variable names are subject to proper camelization.

对它进行了更深入的研究后,发现对许多程序员来说,这是一个非常敏感的问题.他们通常会回答嗯,这只是个人喜好"或这就是我的学习方式".当进一步尝试时,当我试图找到他们使用小骆驼的逻辑原因时,它通常会与人产生某种教条式的反应.

Having dug deeper into it, it turns out that this is a very sensitive issue to many programmers when it is brought to question. They usually answer with, "Well, it's just personal preference" or "That's just how I learned it". Upon prodding further, it usually invokes a sort of dogmatic reaction with the person as I attempt to find a logical reason behind their use of lower camel.

因此,有人想在适当的喜剧类商品中加入一些历史和逻辑吗?

So anyone want to shed a little history and logic behind casing of the proper camelatory variety?

推荐答案

这是两件事的结合:

  • 以小写字母开头的变量约定,以区别于使用大写字母的类或其他实体.有时也可以根据访问级别(私有/公共)来区分它.
  • 使用CamelCasing可以使多个单词的名称在没有空格的情况下更具可读性(当然,这是对下划线(某些人使用的下划线)的优先选择).我猜想逻辑是,对于某些人来说,CamelCasing比word_underscores更加容易/快捷.

它的使用与否当然取决于设置管理所编写代码的编码标准的人.下划线vs CamelCase,小写变量vs大写变量. CamelCase +小写字母变量= camelCase

Whether or not it gets used is of course up to whomever is setting the coding standards that govern the code being written. Underscores vs CamelCase, lowercasevariables vs Uppercasevariables. CamelCase + lowercasevariable = camelCase

这篇关于小写驼峰变量大小写约定(例如thisVariable)的意义是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆