473,406 Members | 2,343 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

underscore prefix

A few times when looking at code on the net I have seen objects,
variables etc prefixed by an underscore. But I've never seen any
explanation for the reason for this. What is the reason for doing this?

Thanks,

Mike

*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #1
4 8284
This is olb naming convention for private variables. In new MS naming
convention you should use m_ as prefix for private members
More information can be found here
http://msdn.microsoft.com/library/de...guidelines.asp
or use FxCop to validate
http://www.gotdotnet.com/team/fxcop/

--
Tamir Khason
You want dot.NET? Just ask:
"Please, www.dotnet.us "
"mike parr" <mp********@yahoo.co.uk> wrote in message
news:Ox**************@TK2MSFTNGP12.phx.gbl...
A few times when looking at code on the net I have seen objects,
variables etc prefixed by an underscore. But I've never seen any
explanation for the reason for this. What is the reason for doing this?

Thanks,

Mike

*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 16 '05 #2
I think the guidlines actually discourage use of m_ when it says "Do
not apply a prefix to field names or static field names."

--
Scott
http://www.OdeToCode.com

On Mon, 5 Jul 2004 11:40:41 +0300, "Tamir Khason"
<ta**********@tcon-NOSPAM.co.il> wrote:
This is olb naming convention for private variables. In new MS naming
convention you should use m_ as prefix for private members
More information can be found here
http://msdn.microsoft.com/library/de...guidelines.asp
or use FxCop to validate
http://www.gotdotnet.com/team/fxcop/


Nov 16 '05 #3
Nothing magical about it; it's just one of many naming conventions for
private class members. I think the underscore prefix is favored by C++
coders.

--Bob

"mike parr" <mp********@yahoo.co.uk> wrote in message
news:Ox**************@TK2MSFTNGP12.phx.gbl...
A few times when looking at code on the net I have seen objects,
variables etc prefixed by an underscore. But I've never seen any
explanation for the reason for this. What is the reason for doing this?

Thanks,

Mike

Nov 16 '05 #4
I think prefixing any variable in a strongly typed environment simply adds
clutter. I find the convention of capitalizing public members but not
private is much more elegant. Just my opinion.

Mike

"Rakesh Rajan" <Ra*********@discussions.microsoft.com> wrote in message
news:F8**********************************@microsof t.com...
Hmm...I have always been in the opinion that whenever we have an exposed member like a public variable or property etc, we should avoid Hungarian
Notation and prefixes of any type. But for private entities, I would use m_
or a prefix... --
Rakesh Rajan
"Scott Allen" wrote:
I think the guidlines actually discourage use of m_ when it says "Do
not apply a prefix to field names or static field names."

--
Scott
http://www.OdeToCode.com

On Mon, 5 Jul 2004 11:40:41 +0300, "Tamir Khason"
<ta**********@tcon-NOSPAM.co.il> wrote:
This is olb naming convention for private variables. In new MS naming
convention you should use m_ as prefix for private members
More information can be found here

http://msdn.microsoft.com/library/de...-us/cpgenref/h

tml/cpconnamingguidelines.asp
or use FxCop to validate
http://www.gotdotnet.com/team/fxcop/


Nov 16 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: jason | last post by:
How do I seperate the "chk_" and "33" in the following string: chk_33 Thanks Jason
5
by: Walter Tross | last post by:
Somebody with a very regulatory mind in this newsgroup has written that it's better not to use a leading underscore for class member names, because names with a leading underscore are used...
9
by: drhowarddrfinedrhoward | last post by:
I see a number of pages with functions like MM_somefunction(). Where does the MM_ come from? I don't see it in any books I'm studying.
38
by: Astra | last post by:
Hi All Could somebody please confirm that if I change my JS expression test from: if (!(/^*$/.test(document.form1.fred.value))) to if (!(/^*$/.test(document.form1.fred.value)))
16
by: Jim Langston | last post by:
I know that functions starting with an underscore, or two underscores, are reserved by the compiler/c++ and should not be used by the user and may cause undefined behavior. My question is, how...
13
by: PromisedOyster | last post by:
Many in our development team have came from a C++ background and are in the practice of prefixing private class variables with an underscore to improve readability and avoid naming collisions with...
18
by: Rob | last post by:
Hi, Would it be safe to prefix private and protected methods and properties with and underscore? Would this cause any issues with other languages? Cheers,
6
by: gara.matt | last post by:
Hi, I was wondering, I've been reading some C++ code written by others, usually libraries and stuff, and I've come across what strikes me as a distinctive style that pervades most of the code...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.