I'll admit - this isn't exactly Umbraco-related, but questions without an exact answer (I want to hear peoples opinions) are frowned upon over at StackOverflow, so here goes:
As a developer, what do you understand by the term camel case?
From what I can tell, the broadest definition of camel case is, that if you refer to it as just camel case, it is assumed to start with a lower case letter - eg. nameOfMyMethod (which can be explicitly be referred to a lower camel casing). On the other hand, if the name would start with an upper case letter - eg NameOfMyMethod it would be called Pascal case (or upper camel case explicitly).
So if I were to create a method that would convert a string to upper camel case, would the best name be ToPascalCase or ToUpperCamelCase. Similar, for a method for converting a string to lower camel case, would the best name be ToCamelCase or ToLowerCamelCase?
I would call it ToCamelCase and it would accept one optional boolean parameter that is defaulted to false. If set to true, it would capitalize the first letter. So:
Note that Umbraco has a lot of built-in string extensions in the Umbraco.Core namespace , such as ToCleanString(), that do something very similar. So don't reinvent the wheel! :)
It has an exact answer. It has been around for decades.
PascalCase and camelCase. Period.
The "sometimes known as" argument is irrelevant. UpperCamelCase doesn't have it's own page on Wikipedia, it's redirected to CamelCase. So there!
This post is cleared as 100% objective scientific researched empiric proof.
For lack of better knowledge, I imagine that a person who insists on calling it UpperCamelCasing is the same kind of person who insist that using the waterfall method and Visual Basic with WebForms is a good idea.
I think I'll go with ToCamelCase and ToPascalCase then.
@Dan Diplo this isn't for an Umbraco package, so I need to implement my own. I already have the code, but just needed to figure how to name my methods.
@Lars-Erik Aabech That was how I understood it as well, but not all people know this. My goal was to find method names that developers are most likely to understand. But it seems that may still be ToCamelCase and ToPascalCase :D
Definition of camel casing?
I'll admit - this isn't exactly Umbraco-related, but questions without an exact answer (I want to hear peoples opinions) are frowned upon over at StackOverflow, so here goes:
As a developer, what do you understand by the term camel case?
From what I can tell, the broadest definition of camel case is, that if you refer to it as just camel case, it is assumed to start with a lower case letter - eg.
nameOfMyMethod
(which can be explicitly be referred to a lower camel casing). On the other hand, if the name would start with an upper case letter - egNameOfMyMethod
it would be called Pascal case (or upper camel case explicitly).So if I were to create a method that would convert a string to upper camel case, would the best name be
ToPascalCase
orToUpperCamelCase
. Similar, for a method for converting a string to lower camel case, would the best name beToCamelCase
orToLowerCamelCase
?Hope this makes sense ;)
Hi Anders,
I have the same understanding as you - and I'd call them
toCamelCase()
andToPascalCase()
just to mess with people :-)Nah - just kidding ;) but I wouldn't use Upper/Lower in the names...
EDIT: So just to be perfectly clear:
In JavaScript, I'd call them
toCamelCase()
andtoPascalCase()
, while in C# they would beToCamelCase()
andToPascalCase()
./Chriztian
I would call it
ToCamelCase
and it would accept one optional boolean parameter that is defaulted to false. If set to true, it would capitalize the first letter. So:Note that Umbraco has a lot of built-in string extensions in the
Umbraco.Core
namespace , such asToCleanString()
, that do something very similar. So don't reinvent the wheel! :)It has an exact answer. It has been around for decades.
PascalCase and camelCase. Period.
The "sometimes known as" argument is irrelevant.
UpperCamelCase doesn't have it's own page on Wikipedia, it's redirected to CamelCase. So there!
This post is cleared as 100% objective scientific researched empiric proof.
For lack of better knowledge, I imagine that a person who insists on calling it UpperCamelCasing is the same kind of person who insist that using the waterfall method and Visual Basic with WebForms is a good idea.
Might be wrong, though. :)
Thanks a lot for the answers.
I think I'll go with
ToCamelCase
andToPascalCase
then.@Dan Diplo this isn't for an Umbraco package, so I need to implement my own. I already have the code, but just needed to figure how to name my methods.
@Lars-Erik Aabech That was how I understood it as well, but not all people know this. My goal was to find method names that developers are most likely to understand. But it seems that may still be
ToCamelCase
andToPascalCase
:DI also think
ToCamelCase()
andToPascalCase()
in C# andtoCamelCase()
andtoPascalCase()
in javascript is clear enough.For my package Color Palettes I also added a camelCase filter: https://github.com/bjarnef/color-palettes/blob/master/ColorPalettes/ColorPalettes/ColorPalettes/filters/camelcase.js
Update
I meant of course PascalCase not UpperCase.
/Bjarne
UPPERCASE is not the same as PascalCase.
Sorry, it was PascalCase I meant :)
:)
The new screaming code style...
Reminds me of BASIC on an Apple II or Commodore 64.
is working on a reply...