1. About.com
  2. Computing & Technology
  3. Delphi

Discuss in my forum

Zarko Gajic

What is the Result of Un-Camel-Casing: "UnCamelCaseTHISString"? I Need Help to Pick the Winning Algorithm :)

By , About.com Guide   October 28, 2009

Follow me on:

in UnCamelCase Challenge ::
While I'm testing and preparing to post the results of the UnCamelCase Challenge, I've run into a small problem :(

What do you expect the result of the UnCamelCase function should be when the string provided is "UnCamelCaseTHISString"?

I have already received more than 50 submission. Some algorithms are fast, some slow, some in a few lines of code, some are "big". Some will be published, some not. BUT, I do have a problem, since I have (obviously) not provided clear instructions for the algorithm .. but that's life :)

Anyway, what do you think the result should be in this case:

Comments
October 28, 2009 at 10:17 am
(1) tonk :

‘Un Camel Case THIS String’?

While you’re iterating, assume that adjacent uppercase letters form a word, until a lowercase letter is found, in which case, reverse a character and split…no?

Obviously it would all depend on how you’ve implemented the original algorithm.

October 28, 2009 at 11:34 am
(2) Henk :

Your sample is not defined as a camel case: “UnCamelCaseTHISString”.

It should be “UnCamelCaseThisString” as you defined it to be in the challenge. The challenge is to uncamel case camel descriptions, which should be as it is intended.

October 28, 2009 at 11:50 am
(3) Zarko Gajic :

@Henk: yep, you’re, in essence, right. However, things happen and I wanted to see what other think of “UnCamelCaseTHISString” :)

October 28, 2009 at 12:00 pm
(4) TDelphiHobbyist :

Zarko, “UnCamelCaseTHISString” is a poorly formatted CamelCase string and should be treated following the rules of GIGO [Garbage In Garbage Out] where the result is:
‘Un Camel Case T H I S String”

Just the same as this input would be:
DidTheProcessWork???

My opinion.

October 28, 2009 at 12:49 pm
(5) Stephen :

I ran into that decision problem as well. Even with the example ILoveDelphi.

IsThisAValidALC would translate into Is-This-A-Valid-A-L-C. Coding, I know ALC is an acronym, but having code realize whats a word, what is an acronym should be out of the scope of this challenge.

October 28, 2009 at 1:00 pm
(6) Diemesse :

UnCamelCaseTHISString will theoretically never process right unless we put a dictionary function into the algorithm. My understanding is that we use CamelCase to make variables readable by substituting caps for spaces.

There are a few cases where CamelCase just doesn’t work out. I have many functions named “EncodeHex”, “HextoFloat”, etc, that work out great. But sometimes I hit a funny one, such as calculating a CRC value. We all recognize CRC as an uppercase abbreviation. Should the CamelCase form be “CRCCalculate”, “CrcCalculate”, or “crcCalculate”? Regardless of what format I choose, I personally would only define CrcCalculate as proper CamelCase, trading caps for spaces.

October 28, 2009 at 2:44 pm
(7) TDelphiHobbyist :

Another valid point, in my opinion, is that if you plan to allow for edge case situations then you must allow for all lower case as well.
The invalid CamelCase “ValidUpperAplhaDtoG” has to come out:
“Valid Upper Aplha D to G”
and not:
“Valid Upper Aplha Dto G”

Edge cases should be considered beyond the scope of the challenge. It would be fun though … using sets of allowable edge case works/acronyms. Certainly doable.


Dave

October 29, 2009 at 10:38 pm
(8) WDHellS :

uncamelcasethisstring

November 4, 2009 at 6:19 am
(9) Peter :

for sure there are some examples that are not covered by all algorithms.
For example, if the CamelCaseWord ends with a capital letter like

ILoveDelphiSaidI

Leave a Comment

Line and paragraph breaks are automatic. Some HTML allowed: <a href="" title="">, <b>, <i>, <strike>
Related Searches casing camel algorithm

©2012 About.com. All rights reserved. 

A part of The New York Times Company.