Name Conventions
-
I typically use an prefixed underscore to indicate private/protected members :) Not that anyone would care :P
I finally got a job doing something I enjoy and I"m good at...15 hour days seem like play time :P
OMG. There's another one us out there that uses this convention. I'm not alone anymore. (sniff)
Software Zen:
delete this;
-
I thought we were talking about methods. For variables and properties, I do the same. upper/lower case differences are not enough to be CLS compiant, because VB sucks.
Christian Graus - C++ MVP 'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
-
OMG. There's another one us out there that uses this convention. I'm not alone anymore. (sniff)
Software Zen:
delete this;
I do, but only for private members. As has been written elsewhere, underscores on protected members will raise errors because they are not CLS Compliant.
the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
Deja View - the feeling that you've seen this post before. -
I do, but only for private members. As has been written elsewhere, underscores on protected members will raise errors because they are not CLS Compliant.
the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
Deja View - the feeling that you've seen this post before.Our naming conventions are something like this:
PascalCase
for public classes, members, 'file'static
values, and globals._PascalCaseWithLeadingUnderscore
for private/protected classes and members.camelCase
orlower_case_with_underscores
for local variables.ALL_UPPER_CASE_FOR_DEFINES
which are required to be manifest constants only. If we ever start doing .NET development (we're currently a C++/MFC house), we may need to modify our conventions. .NET enforcing a naming convention is annoyingly reminiscent of the Ada development tools I had to deal with back in the late 80's. They were equally obnoxious about requiring adherence to some academic's notion of proper programming technique. I am of the "Grady Booch must die" programming school, myself :|.
Software Zen:
delete this;
-
Ennis Ray Lynch, Jr. wrote:
I don't know why the folks at MS tried to dictate a different style.
Because Not Invented Here is alive and rampant at Microsoft. They just, a priori, know what's right.
The evolution of the human genome is too important to be left to chance idiots like CSS.
Tim Craig wrote:
They just, a priori, know what's right
How does an 800 pound gorilla write software? (wait for it) However he likes.
Software Zen:
delete this;
-
Christian Graus wrote:
CLS compiant, because VB sucks.
Wrong, it is because CLS==language independence, a feature it boasts off over Java bytecode. BTW, it is your perfect C# compiler that will complain. If you write and consume your components only in C#, just remove the CLS compliant attribute, and stop blaming VB for your bugs ;P With love, Paul.
Jesus Christ is LOVE! Please tell somebody.
Paul Selormey wrote:
Wrong, it is because CLS==language independence, a feature it boasts off over Java bytecode.
Off topic: Java bytecode is language independent as well, and there are some very nice languages that target JVM, such as Scala[^], Nice[^] and Groovy[^]. Note that I don't count Java as a nice language for JVM ;)
-
Use getValue() in Java and GetValue() in .NET
Upcoming events: * Glasgow Geek Dinner (5th March) * Glasgow: Tell us what you want to see in 2007 My: Website | Blog | Photos
Colin Angus Mackay wrote:
GetValue() in .NET
I'd disagree - for a start I always use getValue, and second off, all the M$ events I've been to recently have had their people using it too... But at the end of the day, I'd say it's COMPLETELY personal preference :)
"Now I guess I'll sit back and watch people misinterpret what I just said......" Christian Graus At The Soapbox
-
Colin Angus Mackay wrote:
GetValue() in .NET
I'd disagree - for a start I always use getValue, and second off, all the M$ events I've been to recently have had their people using it too... But at the end of the day, I'd say it's COMPLETELY personal preference :)
"Now I guess I'll sit back and watch people misinterpret what I just said......" Christian Graus At The Soapbox
RichardGrimmer wrote:
I'd say it's COMPLETELY personal preference
Actually, I'd say it's the preference of whoever will own the code you're writing. If you only code for yourself, then you are correct, if you're coding for others, you should follow their standards, practices, and guidelines. And in my experience, most places that actually understand the concepts of standards and practices tend to follow the guidelines that Christian has already stated. Making them good habits to get into.
Grim
(aka Toby)
MCDBA, MCSD, MCP+SB
SELECT * FROM users WHERE clue IS NOT NULL GO
(0 row(s) affected)
-
Use getValue() in Java and GetValue() in .NET
Upcoming events: * Glasgow Geek Dinner (5th March) * Glasgow: Tell us what you want to see in 2007 My: Website | Blog | Photos
I prefer GetValue() in .NET too. However, if I am trying to port getter/setter methods written in Java to .NET, it is better for me to write them in property syntax. eg (C#):
private int value; /// /// Get and set the value /// public int Value { get { return value; } set { if (this.value != value) this.value = value); } }
You can refer MS website regarding. http://msdn2.microsoft.com/en-us/ms229002(VS.80).aspx[^] :)I like you, and I love programming more.
-
Hello, When i should to name method with uppercase letter and when not? When I should use getValue() and when GetValue()? Thanks.
The problem is more with the name than that case. As long as you consistently use the same casing you won't have a problem. You should pick a better name than GetValue, though. Pick a name that indicates what you are getting - all of your accessor functions are going to "get a value" of some kind. I had a guy a while back who thought it was funny to give his stuff names like "process_something" and "my_string"... this bites you in the ass pretty quick.
"Quality Software since 1983!"
http://www.smoothjazzy.com/ - see the "Programming" section for freeware tools and articles. -
Hello, When i should to name method with uppercase letter and when not? When I should use getValue() and when GetValue()? Thanks.
I reckon if you use .NET you should stick with The Guidelines - Design Guidelines, Managed code and the .NET Framework[^]
-
How about in VB ? ;P
"Courage choose who will follow, Fate choose who will lead" - Lord Gunner, Septerra Core "Press any key to continue, where's the ANY key ?" - Homer Simpsons Drinking gives me amazing powers of insight. I can solve all the worlds problems when drunk, but can never remember the solutions in the morning. - Michael P Butler to Paul Watson on 12/08/03
Wouldn't that be: GETVALUE() ;)
Rocky <>< Latest Code Blog Post: SQL Server Express Warnings & Tips Latest Tech Blog Post: Microsoft doing it again!
-
Steve Hansen wrote:
However, an underscore in any other position in an element name is CLS-compliant.
I understood this as
_element
is invalid, butelement_
,my_element
etc are OK.Steve Hansen wrote:
So it only matters for public properties/methods which I don't think they do.
Agreed.
"Throughout human history, we have been dependent on machines to survive. Fate, it seems, is not without a sense of irony. " - Morpheus
dnh wrote:
I understood this as _element is invalid, but element_, my_element etc are OK.
All ugly and should be banned! ;)
Rocky <>< Latest Code Blog Post: SQL Server Express Warnings & Tips Latest Tech Blog Post: Microsoft doing it again!
-
Use getValue() in Java and GetValue() in .NET
Upcoming events: * Glasgow Geek Dinner (5th March) * Glasgow: Tell us what you want to see in 2007 My: Website | Blog | Photos
Follow a consistent approach regardless of any language. The standardization of naming conventions should be organization-wide and not restricted to any language. Following are the advantages of adhering to common standards: • Programmers can go into any code and figure out the code easily and fast. • New people can get up to speed quickly. • People make fewer mistakes in consistent environments. • Increase the readability and maintainability of the code and hence the productivity of the team. So I would suggest you standardize the coding standards. :rolleyes: I hope this was helpful to you.... Thanks, Nilesh Bhatkhalkar
Cheers, Nilesh Prakash Bhatkhalkar
-
Follow a consistent approach regardless of any language. The standardization of naming conventions should be organization-wide and not restricted to any language. Following are the advantages of adhering to common standards: • Programmers can go into any code and figure out the code easily and fast. • New people can get up to speed quickly. • People make fewer mistakes in consistent environments. • Increase the readability and maintainability of the code and hence the productivity of the team. So I would suggest you standardize the coding standards. :rolleyes: I hope this was helpful to you.... Thanks, Nilesh Bhatkhalkar
Cheers, Nilesh Prakash Bhatkhalkar
NileshBhatkhalkar wrote:
The standardization of naming conventions should be organization-wide and not restricted to any language.
That's nice in theory, but if you look at the standard for Java and the standard for .NET you'll see they are different. If you implement an organisation wide standard that ignores the language you'll end up with two standards in one piece of code. One standard defined by your organisation and one standard defined by the language vendor. I've worked in a company that did that and quite frankly the code was a mess. When I moved to a new language I didn't immediately know where the framework stopped and the company's code started and I got myself in to a right mess when trying to figure out how to call stuff.
NileshBhatkhalkar wrote:
I hope this was helpful to you....
Sorry, but experience has taught me that this is not the way to go. Be as consistent as possible by all means, but yield to the existing standards defined by the language vendor if need be.
Upcoming events: * Glasgow Geek Dinner (5th March) * Glasgow: Tell us what you want to see in 2007 My: Website | Blog | Photos
-
Paul Selormey wrote:
Wrong, it is because CLS==language independence, a feature it boasts off over Java bytecode.
True -and to make it language independant, they needed to make it case insensitive. Which languages are case insensitive ?
Paul Selormey wrote:
BTW, it is your perfect C# compiler that will complain.
Of course it will. The VB.NET compiler is too stupid to see a difference between var, Var and VAR to start with.
Paul Selormey wrote:
just remove the CLS compliant attribute,
I've been known to do that, actually
Paul Selormey wrote:
and stop blaming VB for your bugs
ROTFL - you're obviously kidding around, but either way, I think a language being case insensitive is just plain dumb. It's obviously a 'feature' added to VB.NET to make it easier, it's not something that has a real advantage beyond that.
Christian Graus - C++ MVP 'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
Christian Graus wrote:
Which languages are case insensitive ?
Maybe for the .NET languages you have access to VB.NET. I know of at least Fortran and there is a .NET version.
Christian Graus wrote:
Of course it will. The VB.NET compiler is too stupid to see a difference between var, Var and VAR to start with.
Of what value is the claim that var, Var and VAR are different? Windows is not case sensitive does not make it dump because UNIX/Linux is.
Christian Graus wrote:
ROTFL - you're obviously kidding around, but either way, I think a language being case insensitive is just plain dumb.
Fortran, SQL are case insensitive and I have never found them dump. They do just what they are designed to do and they do it perfectly. I used Fortran for both my MSc and PhD simulations work and never wished I used anything different.
Christian Graus wrote:
It's obviously a 'feature' added to VB.NET to make it easier, it's not something that has a real advantage beyond that.
Neither do I found the case sensitivity of C#/C/C++ to be off any special advantage. I will definitely not have method/function names like getValue and GetValue to mean different things in my code. If you will, simply accept that as a personal preference and has nothing to do with programming skill or whatever. The history of C, the mother of C#, tells you why they needed a case sensitivity. With love, Paul.
Jesus Christ is LOVE! Please tell somebody.
-
I reckon if you use .NET you should stick with The Guidelines - Design Guidelines, Managed code and the .NET Framework[^]
-
Christian Graus wrote:
Which languages are case insensitive ?
Maybe for the .NET languages you have access to VB.NET. I know of at least Fortran and there is a .NET version.
Christian Graus wrote:
Of course it will. The VB.NET compiler is too stupid to see a difference between var, Var and VAR to start with.
Of what value is the claim that var, Var and VAR are different? Windows is not case sensitive does not make it dump because UNIX/Linux is.
Christian Graus wrote:
ROTFL - you're obviously kidding around, but either way, I think a language being case insensitive is just plain dumb.
Fortran, SQL are case insensitive and I have never found them dump. They do just what they are designed to do and they do it perfectly. I used Fortran for both my MSc and PhD simulations work and never wished I used anything different.
Christian Graus wrote:
It's obviously a 'feature' added to VB.NET to make it easier, it's not something that has a real advantage beyond that.
Neither do I found the case sensitivity of C#/C/C++ to be off any special advantage. I will definitely not have method/function names like getValue and GetValue to mean different things in my code. If you will, simply accept that as a personal preference and has nothing to do with programming skill or whatever. The history of C, the mother of C#, tells you why they needed a case sensitivity. With love, Paul.
Jesus Christ is LOVE! Please tell somebody.
Paul Selormey wrote:
I know of at least Fortran and there is a .NET version.
OK, I didn't know that. I wonder mow many computers used upper and lower case when FORTRAN was developed ?
Paul Selormey wrote:
The history of C, the mother of C#
You're totally wrong. C has nothing to do with C#, and C++ has next to nothing to do with C#. They are totally unrelated.
Christian Graus - C++ MVP 'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
-
Follow a consistent approach regardless of any language. The standardization of naming conventions should be organization-wide and not restricted to any language. Following are the advantages of adhering to common standards: • Programmers can go into any code and figure out the code easily and fast. • New people can get up to speed quickly. • People make fewer mistakes in consistent environments. • Increase the readability and maintainability of the code and hence the productivity of the team. So I would suggest you standardize the coding standards. :rolleyes: I hope this was helpful to you.... Thanks, Nilesh Bhatkhalkar
Cheers, Nilesh Prakash Bhatkhalkar
-
Christian Graus wrote:
Which languages are case insensitive ?
Maybe for the .NET languages you have access to VB.NET. I know of at least Fortran and there is a .NET version.
Christian Graus wrote:
Of course it will. The VB.NET compiler is too stupid to see a difference between var, Var and VAR to start with.
Of what value is the claim that var, Var and VAR are different? Windows is not case sensitive does not make it dump because UNIX/Linux is.
Christian Graus wrote:
ROTFL - you're obviously kidding around, but either way, I think a language being case insensitive is just plain dumb.
Fortran, SQL are case insensitive and I have never found them dump. They do just what they are designed to do and they do it perfectly. I used Fortran for both my MSc and PhD simulations work and never wished I used anything different.
Christian Graus wrote:
It's obviously a 'feature' added to VB.NET to make it easier, it's not something that has a real advantage beyond that.
Neither do I found the case sensitivity of C#/C/C++ to be off any special advantage. I will definitely not have method/function names like getValue and GetValue to mean different things in my code. If you will, simply accept that as a personal preference and has nothing to do with programming skill or whatever. The history of C, the mother of C#, tells you why they needed a case sensitivity. With love, Paul.
Jesus Christ is LOVE! Please tell somebody.
Paul Selormey wrote:
The history of C, the mother of C#, tells you why they needed a case sensitivity.
Can you please say why?:)
Regards, --=A J E E S H=--