Dim Form as Form OK用法??? [英] Dim Form as Form OK usage???

查看:106
本文介绍了Dim Form as Form OK用法???的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我曾在一些地方尝试使用变量名表格,它似乎是

OK。

例如:

Public Shared Sub WritePositionsInRegistry(ByVal Form As Form,ByVal

SubkeyName As String)


使用Type名称作为变量名称是否可以。例如:


设置(ByVal颜色为颜色)


有时我不会想到一个合适的参数名称,除了输入名称。


谢谢


I''ve tried in a few places using a variable name Form and it appears to be
OK.
For example:
Public Shared Sub WritePositionsInRegistry(ByVal Form As Form, ByVal
SubkeyName As String)

Is it OK to use a Type name as a variable name. For example,:

Set(ByVal Color As Color)

Sometimes I can''t think of a fitting argument name other then the Type name.

Thanks


推荐答案

这会被认为是非常的以这种方式编写程序的糟糕形式。由于

很多Type类型具有可以直接调用的共享函数,因此它使得你的程序很难读懂。特别是当你可以使用

简单前缀修复问题时。


公共共享子WritePositionsInRegistry(ByVal frmForm As Form,ByVal

SubkeyName As String)


只需我的两分钱

克里斯


"只是我 < GR **** @ a-znet.com>在消息中写道

新闻:OC ************** @ tk2msftngp13.phx.gbl ...
It would be considered very bad form to write a program this way. Since a
lot of Type names have shared function that can called directly, it makes
your program hard to read. Espcially when you can fix the problem with a
simple prefix.

Public Shared Sub WritePositionsInRegistry(ByVal frmForm As Form, ByVal
SubkeyName As String)

Just my two cents
Chris

" Just Me" <gr****@a-znet.com> wrote in message
news:OC**************@tk2msftngp13.phx.gbl...
我试过了在一些地方使用变量名表格,它似乎是
好的。
例如:
公共共享子WritePositionsInRegistry(ByVal表格作为表格,ByVal
SubkeyName作为字符串)

使用Type名称作为变量名称是否可以。例如:

设置(ByVal颜色为颜色)

有时我不会想到一个合适的参数名称,而不是Type
名称。

谢谢
I''ve tried in a few places using a variable name Form and it appears to be
OK.
For example:
Public Shared Sub WritePositionsInRegistry(ByVal Form As Form, ByVal
SubkeyName As String)

Is it OK to use a Type name as a variable name. For example,:

Set(ByVal Color As Color)

Sometimes I can''t think of a fitting argument name other then the Type
name.

Thanks



只是我,

有一群开发者,比如作为克里斯,谁觉得使用类型

名称变量是一件坏事。还有另一组开发人员,通常是OO开发人员,他们觉得使用变量名称的类型名称

可能是一个好主意。

我倾向于落入第二组,因为这是我解释

参数命名指南的方式
http://msdn.microsoft.com/library /de...Guidelines.asp

来自类库开发人员的.NET设计指南。


为参数命名类型可能是最合适的,因为它:

- 描述性名称 - ''form''可能是变量

最具描述性的名称,给出了它的使用方法。 parentForm或childForm可能是更好的名字。

- 描述一个参数的含义 - 恕我直言,其明显的''形式''表示形式。 :-)

- 不要用匈牙利语符号表示前缀参数名称(恕我直言frmForm

是复制,许多OO开发人员试图避免重复,其

避免重复是重构的主要内容
http:// www .refactoring.com


另外上面的指南建议不要缩写名称,''形式''更好

然后''frm ''。是Form,Farm还是功能资源经理的简称?

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

换句话说,而不是像克里斯建议的那样frmForm我会考虑

formParent,或者parentForm。取决于我正在做什么将决定我是否使用类型作为前缀或后缀...有时我只是使用父母或孩子

如果其明显的话。在上下文中变量表示的内容,记住变量的变量类型也有助于变量的含义...


还有另一组开发人员(主要是Java)更喜欢在

名称前添加the,a和a。或一个或一个 (a,如单数而非匈牙利数组

前缀),这使得代码更容易。读作英语。


公共共享子WritePositionsInRegistry(ByVal theForm As Form)

For the each aChild作为theForm.Controls中的控件

aChild.BackColor = theForm.BackColor

下一页

结束子


你找到the,a ;和和在Martin Fowler的重构书中有很多,因为

所有的样本都是用Java编写的。


如果我的商店有需要的前缀(匈牙利语)保持原样我会推荐第三种方法,因为它具有可读性......


希望这有助于

Jay

"只是我 < GR **** @ a-znet.com>在消息中写道

新闻:OC ************** @ tk2msftngp13.phx.gbl ...
Just Me,
There are a group of developers, such as Chris, who feel that using the type
name for the variable is a bad thing. There are another group of developers,
usually OO developers, who feel using the type name for the variable name
may be a good idea.

I tend to fall into this second group, as that is the way I interpret the
"Parameter Naming Guidelines"
http://msdn.microsoft.com/library/de...Guidelines.asp
from the ".NET Design Guidelines for Class Library Developers".

Naming the parameter for the type may be the best fit because its:
- a descriptive name - ''form'' may be the most descriptive name for variable
given how its used. parentForm or childForm may be better names.
- describe a parameter''s meaning - IMHO its obvious ''form'' means form. :-)
- Do not prefix parameter names with Hungarian type notation (IMHO frmForm
is "duplication", a number of OO developers try to avoid duplication, its
avoid duplication is a major tenent of Refactoring
http://www.refactoring.com)

Also the above guidelines suggest not to abbreviate names, ''form'' is better
then ''frm''. Is frm short for Form, Farm, or Functional Resources Manager?

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

In other words, rather then frmForm as Chris suggests I would consider
formParent, or parentForm. Depending on what I am doing would decide if I
use the type as a prefix or suffix... Sometimes I simply use parent or child
if its "obvious" in the context what the variable represents, remember the
type of the variable also contributes to the meaning of the variable...

There is another group of developers, mostly Java, that prefer to prefix the
name with "the", "a" or "an" ("a" as in singular not a Hungarian array
prefix), which makes the code "easier" to read as English.

Public Shared Sub WritePositionsInRegistry(ByVal theForm As Form)
For Each aChild As Control in theForm.Controls
aChild.BackColor = theForm.BackColor
Next
End Sub

You find "the", "a", and "an" a lot in Martin Fowler''s Refactoring book, as
all the samples are in Java.

If my shop had a perceived need for prefixes (Hungarian hold overs) I would
promote the third method, for its perceived readability...

Hope this helps
Jay
" Just Me" <gr****@a-znet.com> wrote in message
news:OC**************@tk2msftngp13.phx.gbl...
我试过了在一些地方使用变量名表格,它似乎是
好的。
例如:
公共共享子WritePositionsInRegistry(ByVal表格作为表格,ByVal
SubkeyName作为字符串)

使用Type名称作为变量名称是否可以。例如:

设置(ByVal颜色为颜色)

有时我不会想到一个合适的参数名称,而不是Type
名称。

谢谢
I''ve tried in a few places using a variable name Form and it appears to be
OK.
For example:
Public Shared Sub WritePositionsInRegistry(ByVal Form As Form, ByVal
SubkeyName As String)

Is it OK to use a Type name as a variable name. For example,:

Set(ByVal Color As Color)

Sometimes I can''t think of a fitting argument name other then the Type
name.

Thanks



我同意frmForm是redunant。 frmMain是我一直以来的做法,但是这是来自一个没有在一个拥有大型团队的公司工作的人,而且必须标准化命名约定。关于这个想法的非常好的写作

Jay。


Chris

" Jay B. Harlow [MVP - Outlook] " < JA ************ @ msn.com>在留言中写道

news:%2 **************** @ TK2MSFTNGP09.phx.gbl ...
I agree that frmForm is redunant. frmMain is how I have always done it, but
this is from someone that has not had to work in a company with large teams
and had to standardize naming conventions. Very nice write-up on this idea
Jay.

Chris
"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Just Me ,
有一群开发人员,比如Chris,他们觉得使用
类型名称作为变量是件坏事。还有另一组开发人员,通常是OO开发人员,他们觉得使用
变量名称的类型名称可能是一个好主意。

我倾向于落入第二小组,因为这是我解释
参数命名指南的方式
http://msdn.microsoft.com/library/de...Guidelines.asp
来自类库开发人员的.NET设计指南。

为该类型命名参数可能是最合适的,因为它:
- 描述性名称 - 表单鉴于其使用方式,可能是
变量最具描述性的名称。 parentForm或childForm可能是更好的名字。
- 描述一个参数的含义 - 恕我直言,其明显的''形式''表示形式。 :-)
- 不要用匈牙利语符号表示前缀参数名称(恕我直言frmForm
是复制,一些OO开发人员试图避免重复,它的
避免重复是一个主要的重构的内容
http://www.refactoring.com

上述指南也建议不要缩写名称,''形式''比
更好''frm''。是表单,农场或功能资源的简称
经理吗?

http://msdn.microsoft.com/library/de...reviations.asp
换句话说,而不是像克里斯建议的那样frmForm我会考虑
formParent或parentForm。取决于我正在做什么将决定我是否使用该类型作为前缀或后缀...有时我只是使用父或
孩子,如果它的显而易见。在上下文中变量代表什么,
记住变量的类型也有助于变量的含义...

还有另一组开发人员,主要是Java ,更喜欢在名称前加上the,a和a。或一个或一个 (a,如单数而非匈牙利数组
前缀),这使得代码更容易。英文阅读。

公共共享子WritePositionsInRegistry(ByVal theForm As Form)
对于每个aChild作为theForm.Controls中的控件
aChild.BackColor = theForm.BackColor 下一页
End Sub

您会找到the,a和an。 Martin Fowler的重构书中有很多,
因为所有的样本都是用Java编写的。

如果我的商店需要前缀(匈牙利语暂停)我会
会推广第三种方法,因为它具有可读性......

希望这有助于
Jay

"只是我 < GR **** @ a-znet.com>在消息中写道
新闻:OC ************** @ tk2msftngp13.phx.gbl ...
Just Me,
There are a group of developers, such as Chris, who feel that using the
type name for the variable is a bad thing. There are another group of
developers, usually OO developers, who feel using the type name for the
variable name may be a good idea.

I tend to fall into this second group, as that is the way I interpret the
"Parameter Naming Guidelines"
http://msdn.microsoft.com/library/de...Guidelines.asp
from the ".NET Design Guidelines for Class Library Developers".

Naming the parameter for the type may be the best fit because its:
- a descriptive name - ''form'' may be the most descriptive name for
variable given how its used. parentForm or childForm may be better names.
- describe a parameter''s meaning - IMHO its obvious ''form'' means form. :-)
- Do not prefix parameter names with Hungarian type notation (IMHO frmForm
is "duplication", a number of OO developers try to avoid duplication, its
avoid duplication is a major tenent of Refactoring
http://www.refactoring.com)

Also the above guidelines suggest not to abbreviate names, ''form'' is
better then ''frm''. Is frm short for Form, Farm, or Functional Resources
Manager?

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

In other words, rather then frmForm as Chris suggests I would consider
formParent, or parentForm. Depending on what I am doing would decide if I
use the type as a prefix or suffix... Sometimes I simply use parent or
child if its "obvious" in the context what the variable represents,
remember the type of the variable also contributes to the meaning of the
variable...

There is another group of developers, mostly Java, that prefer to prefix
the name with "the", "a" or "an" ("a" as in singular not a Hungarian array
prefix), which makes the code "easier" to read as English.

Public Shared Sub WritePositionsInRegistry(ByVal theForm As Form)
For Each aChild As Control in theForm.Controls
aChild.BackColor = theForm.BackColor
Next
End Sub

You find "the", "a", and "an" a lot in Martin Fowler''s Refactoring book,
as all the samples are in Java.

If my shop had a perceived need for prefixes (Hungarian hold overs) I
would promote the third method, for its perceived readability...

Hope this helps
Jay
" Just Me" <gr****@a-znet.com> wrote in message
news:OC**************@tk2msftngp13.phx.gbl...
我试过几个地方使用变量名表格,它似乎没问题。
例如:
Public Shared Sub WritePositionsInRegistry(ByVal Form As Form,ByVal
SubkeyName As String)

使用Type名称作为变量名称是否可以。例如:

设置(ByVal颜色为颜色)

有时我不会想到一个合适的参数名称,而不是Type
名称。

谢谢
I''ve tried in a few places using a variable name Form and it appears to
be OK.
For example:
Public Shared Sub WritePositionsInRegistry(ByVal Form As Form, ByVal
SubkeyName As String)

Is it OK to use a Type name as a variable name. For example,:

Set(ByVal Color As Color)

Sometimes I can''t think of a fitting argument name other then the Type
name.

Thanks




这篇关于Dim Form as Form OK用法???的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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