Re: Dim Form as Form OK usage???
From: Jay B. Harlow [MVP - Outlook] (Jay_Harlow_MVP_at_msn.com)
Date: 12/09/04
- Next message: Herfried K. Wagner [MVP]: "Re: Problem running BAT file containing CHCP"
- Previous message: Herfried K. Wagner [MVP]: "Re: from a tutorial"
- In reply to: Just Me: "Dim Form as Form OK usage???"
- Next in thread: Chris, Master of All Things Insignificant: "Re: Dim Form as Form OK usage???"
- Reply: Chris, Master of All Things Insignificant: "Re: Dim Form as Form OK usage???"
- Reply: Larry Serflaten: "Re: Dim Form as Form OK usage???"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 9 Dec 2004 14:37:12 -0600
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/default.asp?url=/library/en-us/cpgenref/html/cpconParameterNamingGuidelines.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?
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" <groups@a-znet.com> wrote in message
news:OCSZkNi3EHA.4004@tk2msftngp13.phx.gbl...
> 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
>
>
>
>
- Next message: Herfried K. Wagner [MVP]: "Re: Problem running BAT file containing CHCP"
- Previous message: Herfried K. Wagner [MVP]: "Re: from a tutorial"
- In reply to: Just Me: "Dim Form as Form OK usage???"
- Next in thread: Chris, Master of All Things Insignificant: "Re: Dim Form as Form OK usage???"
- Reply: Chris, Master of All Things Insignificant: "Re: Dim Form as Form OK usage???"
- Reply: Larry Serflaten: "Re: Dim Form as Form OK usage???"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|