命名约定最佳实践 [英] Naming conventions best practise

查看:66
本文介绍了命名约定最佳实践的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个开发人员已经定义了我们的可变命名约定,他已经定义了变量的名称与它们的类相同。

实例,for例如:


Syste.Xml.XmlDocument XmlDocument;


我发现这是一个非常糟糕的主意,因为你可能会对XmlDocument的内容感到困惑/>
是一个变量或类。对于这样的命名约定,你们中的任何一个人都有一些好的论据或者说是
吗?是否有可能用这样的命名约定来实际制作

模糊代码,如果你的意思是类或变量,编译器就不会知道



亲切的问候,

Allan Ebdrup

We have a developer who has defined our vraiable naming conventions, He has
defined that variables should benamed the same as the class they are an
instance of, for example:

Syste.Xml.XmlDocument XmlDocument;

I find this a very bad idea as you might get confused about what XmlDocument
is, a variabel or a class. Do any of you have some good arguments for or
against such a naming convention? Would it be possible to actually make
ambiguous code with such a naming conventions where the compiler wouldn''t
know if you mean the class or the variable?

Kind Regards,
Allan Ebdrup

推荐答案

请参考

http://msdn.microsoft.com/library/de...gpractices.asp


问候

Prakash Prabhu K

" Allan Ebdrup"写道:
Please refer

http://msdn.microsoft.com/library/de...gpractices.asp

Regards
Prakash Prabhu K
"Allan Ebdrup" wrote:
我们有一个开发人员已经定义了我们的可变命名约定,他已经定义了变量的名称应该与它们的类相同。
实例例如:

Syste.Xml.XmlDocument XmlDocument;

我发现这是一个非常糟糕的主意,因为你可能会对XmlDocument是什么感到困惑,变异或类。你们中有人对这样的命名惯例有一些好的论据吗?是否可以用这样的命名约定来实际制作含糊不清的代码,编译器不会知道你是指类还是变量?

亲切的问候,
Allan Ebdrup
We have a developer who has defined our vraiable naming conventions, He has
defined that variables should benamed the same as the class they are an
instance of, for example:

Syste.Xml.XmlDocument XmlDocument;

I find this a very bad idea as you might get confused about what XmlDocument
is, a variabel or a class. Do any of you have some good arguments for or
against such a naming convention? Would it be possible to actually make
ambiguous code with such a naming conventions where the compiler wouldn''t
know if you mean the class or the variable?

Kind Regards,
Allan Ebdrup



在消息< Oy ************** @ TK2MSFTNGP15 .phx.gbl>,Allan Ebdrup

< co **** @ ofir.com>写道
In message <Oy**************@TK2MSFTNGP15.phx.gbl>, Allan Ebdrup
<co****@ofir.com> writes
我们有一个开发人员定义了我们的可变命名约定,他已经定义了变量的名称应该与它们的类相同,例如:

Syste.Xml.XmlDocument XmlDocument;

我发现这是一个非常糟糕的主意,因为你可能会对XmlDocument
,变量或类感到困惑。你们中有人对这样的命名惯例有一些好的论据吗?是否可以用这样的命名约定来实际制作含糊不清的代码,编译器不会知道你是指类还是变量?
We have a developer who has defined our vraiable naming conventions, He has
defined that variables should benamed the same as the class they are an
instance of, for example:

Syste.Xml.XmlDocument XmlDocument;

I find this a very bad idea as you might get confused about what XmlDocument
is, a variabel or a class. Do any of you have some good arguments for or
against such a naming convention? Would it be possible to actually make
ambiguous code with such a naming conventions where the compiler wouldn''t
know if you mean the class or the variable?



它导致静态方法的intellisense出现问题。如果他想用b $ b来使用它,他应该使用变量名称来表示。我不会把它当作一个严格的标准。有时,类名(适当地加入)也是变量名的好候选者。有时它不是。


-

Steve Walker



It causes problems with intellisense for static methods. If he wants to
use it, he should camel-case the variable name. I wouldn''t adopt it as a
rigid standard. Sometimes the class name (appropriately cased) is also a
good candidate for a variable name. Sometimes it isn''t.

--
Steve Walker


" Prakash Prabhu K" <镨************ @ discussions.microsoft.com>写在

消息新闻:0F ********************************** @ microsof t.com ...
"Prakash Prabhu K" <Pr************@discussions.microsoft.com> wrote in
message news:0F**********************************@microsof t.com...
请参考

http://msdn.microsoft.com/library/de...gpractices.asp




那很好,但是我看不出哪里可以解决我写的问题。



That''s fine but I can''t see where that addresses the issue I write about.


这篇关于命名约定最佳实践的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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