This post has been edited by Vermiculus: 17 June 2010 - 05:47 AM
CamelCase or PascalCaseWhich is Better?
25 Replies - 7600 Views - Last Post: 20 June 2010 - 04:26 PM
#1
CamelCase or PascalCase
Posted 16 June 2010 - 01:16 PM
Advantages/disadvantages of each? It doesn't make a difference run-time, so it's all readability and preference.
Replies To: CamelCase or PascalCase
#2
Re: CamelCase or PascalCase
Posted 16 June 2010 - 01:19 PM
In my opinion it's purely preference and readability. I've worked for places that had a coding standard of only camel case and some that only allowed pascal. It makes no difference as far as performance. I will say that people need to pick one and stick with it. It sucks to look through someone's code where they mix and match
#3
Re: CamelCase or PascalCase
Posted 16 June 2010 - 01:20 PM
Not sure you have your definitions right. Camel-case can have an initial lower case letter as well.
I prefer:
Class names: uppercase + camel case
functions: lower case+ camel case
I prefer:
Class names: uppercase + camel case
functions: lower case+ camel case
#4
Re: CamelCase or PascalCase
Posted 16 June 2010 - 01:53 PM
I used to use CamelCase exclusively, but then I took a systems course and I find myself using underscores to separate words rather than case.
#5
Re: CamelCase or PascalCase
Posted 16 June 2010 - 01:56 PM
Egads, I hate underscores.
Well not 100% true, at times I catch myself using them when writing in MSSQL.
For code though I prefer camel casing personally, it's just easier for me to read and look at.
Well not 100% true, at times I catch myself using them when writing in MSSQL.
For code though I prefer camel casing personally, it's just easier for me to read and look at.
#6
Re: CamelCase or PascalCase
Posted 16 June 2010 - 02:03 PM
The only thing worse then underscores is Hungarian notation. Woof.
#7
Re: CamelCase or PascalCase
Posted 16 June 2010 - 04:56 PM
lol. I only use underscores when using hungarian notation. And when used properly, Hungarian notation makes fiddly mistakes jump out!
double currentTime_s = 130; double currentTime_min = currentTime_s / 60.0; double totalTime_s = endTime_min - startTime_s; // spot this error a mile away ;)/>
#8
Re: CamelCase or PascalCase
Posted 16 June 2010 - 05:44 PM
As others have noted, it's all personal preference. I tend to use camelCase more.
#9
Re: CamelCase or PascalCase
Posted 17 June 2010 - 02:12 AM
Is it just me or is there a problem with the poll?
camelCase starts as KYA said with a lower case letter.
PascalCase starts with an upper case letter, so the poll should have looked like:
camelCase: addressTextBox
PascalCase: AddressTextBox
Hungarian: txtAddress (Not sure about this)
camelCase starts as KYA said with a lower case letter.
PascalCase starts with an upper case letter, so the poll should have looked like:
camelCase: addressTextBox
PascalCase: AddressTextBox
Hungarian: txtAddress (Not sure about this)
#10
Re: CamelCase or PascalCase
Posted 17 June 2010 - 03:13 AM
Quote
Hungarian: txtAddress (Not sure about this)
This is a common misconception and it gives Hungarian notation a bad name. Something like this:
String strAddress = new String("10 Leafy St");
Here the type (String) tells you it is a string or text. Putting that information in the variable name as well is just clutter.
Hungarian notation is useful for keeping track of units or relative offsets. Is that mouse coordinate relative to the screen or the window?
#11
Re: CamelCase or PascalCase
Posted 17 June 2010 - 03:14 AM
Vestah, on 17 June 2010 - 01:12 AM, said:
Is it just me or is there a problem with the poll?
camelCase starts as KYA said with a lower case letter.
PascalCase starts with an upper case letter, so the poll should have looked like:
camelCase: addressTextBox
PascalCase: AddressTextBox
Hungarian: txtAddress (Not sure about this)
camelCase starts as KYA said with a lower case letter.
PascalCase starts with an upper case letter, so the poll should have looked like:
camelCase: addressTextBox
PascalCase: AddressTextBox
Hungarian: txtAddress (Not sure about this)
Yeah the OP got it wrong which is why I didn't vote and just replied with correct casing lol
#12
Re: CamelCase or PascalCase
Posted 17 June 2010 - 05:53 AM
Vestah, on 17 June 2010 - 03:12 AM, said:
Is it just me or is there a problem with the poll?
camelCase starts as KYA said with a lower case letter.
PascalCase starts with an upper case letter, so the poll should have looked like:
camelCase: addressTextBox
PascalCase: AddressTextBox
Hungarian: txtAddress (Not sure about this)
camelCase starts as KYA said with a lower case letter.
PascalCase starts with an upper case letter, so the poll should have looked like:
camelCase: addressTextBox
PascalCase: AddressTextBox
Hungarian: txtAddress (Not sure about this)
Yes, there was a problem with the poll. I was reading a little article-type-thing about this earlier yesterday, and didn't do much further research on it. but Wikipedia did confirm the CamelCase starts every word with a capital (if it's a class/struct/etc) and starts only the first word with a lower (if it's a parameter/variable/etc). So it seems that Pascal Case (or Pascal style as Wikipedia calls it) is only the subset of CamelCase where the first letter is not capitalized.
Hungarian notation is the one with the short abbr. at the beginning (txtAddress). My fault; I have revised the poll. Also added a question concerning underscores. I say burnThem.
http://en.wikipedia....ming_convention
http://en.wikipedia....garian_notation
#13
Re: CamelCase or PascalCase
Posted 17 June 2010 - 06:22 AM
I used to hate the underscores, now they don't bother me. Basically I just try to avoid mixing naming styles within a system these days.
#14
Re: CamelCase or PascalCase
Posted 17 June 2010 - 06:27 AM
I tend to go with java conventions. Keeps my code readable.
ClassNames
variableAndMethodNames
CONSTANT_NAMES
Hungarian notation gets added in whenever it clarifies things. (I would never use the example in your poll though)
Particularly in unit tests I do things like:
testCustomSort_arrayWithDuplicates
Basically, I use whatever convention makes my code easier to understand.
ClassNames
variableAndMethodNames
CONSTANT_NAMES
Hungarian notation gets added in whenever it clarifies things. (I would never use the example in your poll though)
Particularly in unit tests I do things like:
testCustomSort_arrayWithDuplicates
Basically, I use whatever convention makes my code easier to understand.
#15
Re: CamelCase or PascalCase
Posted 17 June 2010 - 07:35 AM
I primarily use camel case without underscores but sometimes when writing C I catch myself using them...just feels...right. No idea why but it's how I roll.