在java中有一个标准用于_(下划线)在变量或类名前面吗? [英] Is there a standard in java for _ (underscore) in front of variable or class names?

查看:536
本文介绍了在java中有一个标准用于_(下划线)在变量或类名前面吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经看到一些程序员在类名前面使用 _ (下划线),其他程序员使用它作为局部变量。

I have seen some programmers using _ (underscore) in front of class names, and others using it for local variables.

Java标准需要/建议在私有实例变量或类名前使用_(下划线)吗?

Does the Java standard require/suggest the use of _ (underscore) in front of an private instance variable or class name?

推荐答案

这是一个个人品味的问题。

It is a matter of personal taste.

Martin Fowler似乎喜欢。我不在乎它 - 它打破了阅读模式,它传达的信息已经巧妙地通过颜色在你的IDE。

Martin Fowler appears to like it. I don't care much for it - it breaks the reading pattern, and the information it conveys is already subtly told by color in your IDE.

我已经试验过使用 _ 作为保存方法返回结果的变量的名称。这是非常简洁,但我最后认为 result 更好。

I've experimented with using _ as the name of the variable holding the result to be returned by a method. It is very concise, but I've ended up thinking that the name result is better.

你的同事们就你最喜欢的东西达成一致,然后就这样做。

So, get your colleagues to agree on what you all like the most and then just do that.

这篇关于在java中有一个标准用于_(下划线)在变量或类名前面吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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