Re: Member Variables Naming Convention



Hi Jonathan,

Well I was going to look that up again but I see you gave me a trick question. I just stated in
the post you were replying to that I considered references to controls a bit different than
straight variables. Perhaps you didn't read my entire post, eh? We were talking about member
variables.

I read your entire post. No tricks here :)

We are talking about fields (member variables, as you say), which txtFirstName and lblFirstName
certainly are.

How would you name these two Controls?

Well, as I indicated, I consider that a different issue. I haven't decided on this issue for sure,
but I have a tendancy to stick with what I did in VB, which is to include those prefixes.

I don't see it as a different issue at all. They are fields. (but the point is a moot one anyway
since you were right...)

BTW, I found two interesting bullets in a Microsoft document [link below] regarding the use of
hungarian notation and the "_" prefix in field names:

- Do not use Hungarian notation for field names. Good names describe semantics, not type.

I must argue here that my examples of txtFirstName and lblFirstName indicate both type and
semantics. However, I use the notation in other controls even when there is no ambiguity, but I'm
going to try to break that habit for my next project. Do I really need to know that a field is a
Control by looking at its name when I have intellisense and tooltips on hand at all times? - I
don't think so, but I'll see how it goes ;)

- Do not apply a prefix to field names or static field names. Specifically, do not apply a prefix to
a field name to distinguish between static and nonstatic fields. For example, applying a g_ or s_
prefix is incorrect.

"Field Usage Guidelines [.NET Framework]"
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconfieldusageguidelines.asp?frame=true

--
Dave Sexton


.



Relevant Pages

  • Re: Member Variables Naming Convention
    ... references to controls a bit different than straight variables. ... Actually, in the Microsoft guidelines, it really is. ... Hungarian notation isn't completely outlawed, ... any argument for me to adopt the "_" prefix as my personal style. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Member Variables Naming Convention
    ... Actually, in the Microsoft guidelines, it really is. ... Hungarian notation isn't completely outlawed, ... this notation when I need to distinguish between controls that would otherwise have identical ... Having suffered from carpel-tunnel issues from time to time, I'm not going to prefix every ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: difference between assembly in aspx page and web.config?
    ... tagPrefix is used to define a prefix to identify 3rd party controls. ... Should not the vendor have built the sofware so that a drop from the VS2005 toolkit puts the correct assembly info in the web.config? ... While I no longer need to have those prefix registration, I am still having this problem that I posted earlier: ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Framework-generated ID woes
    ... No way to specify the ID prefix? ... this ClientID property ... Bruno Alexandre wrote: ... I have lots of controls on my ASP.NET 2.0 page, ...
    (microsoft.public.dotnet.framework.aspnet)