3

As the title says how would camel case, which is: theQuickBrownFox, work when one of the words starts with a lower case letter followed by a capital such as is the case in iPhone.

getiPhoneNumber() for instance looks weird.

Would it be getIphoneNumber() or getIPhoneNumber() or what?

what if it was the first word? iPhoneNumber vs iphoneNumber? Since only each different word should be capitalized.

Aequitas
  • 2,205
  • 1
  • 25
  • 51
  • I'm voting to close this question as off-topic because it belongs on programmers.stackexchange.com – leppie Jul 11 '15 at 22:24
  • 1
    @leppie **[What goes on Programmers.SE? A guide for Stack Overflow](http://meta.programmers.stackexchange.com/q/7182/22815)**. –  Jul 11 '15 at 23:21
  • @Snowman: it is opinionated and does not belong on SO as it involves not a programming problem. Please suggest where then. – leppie Jul 11 '15 at 23:27
  • 1
    @leppie Nowhere. "Primary opinion-based" is a close reason at Programmers, same as here. Specifically, questions about code style and naming tend to go over like a Led Zeppelin at Programmers. –  Jul 11 '15 at 23:29
  • @Snowman: Still this not a coding issue. Does not belong on SO. Maybe not suited for anything (sorry if I offended the PSE community). – leppie Jul 11 '15 at 23:34
  • 1
    @leppie no offense taken. I agree this does not belong anywhere. –  Jul 12 '15 at 00:09
  • @Snowman how is it an opinion? Surely there are rules for camelcase in cases such as this? – Aequitas Jul 12 '15 at 01:43
  • 1
    @Aequitas there are as many naming conventions as there are people to name them. Even constraining it as "camel case" there are different variations, and different people will strongly advocate for their favorite. –  Jul 12 '15 at 18:20

1 Answers1

-1

Any algorithm that separates a camel case identifier back into individual words would correctly produce: get IPhone number from getIPhoneNumber and would be fooled by getiPhoneNumber because it would separate this into geti phone number. Therefore, the correct naming is getIPhoneNumber.

Using the very same criterion I would use iphoneNumber rather than iPhoneNumber.

EDIT

Given that there is some consensus about this question being opinion-based I would like to say that any criterion on how to capitalize a sentence using the camel case convention shouldn't be opinion based but consistent with whatever separation algorithm one would happen to use.

Leandro Caniglia
  • 14,495
  • 4
  • 29
  • 51
  • By that logic wouldn't it be seperated into `get` `i` `phone` `number` ? judging by the second paragraph I think you meant: `getIphoneNumber`? – Aequitas Jul 12 '15 at 09:34
  • No, because consecutive uppercase letters usually appear in identifiers and therefore a (good) separating algorithm should keep them together. Therefore `getIPhoneNumber` should get split between `t` and `I` and not between `I` and `P`. – Leandro Caniglia Jul 12 '15 at 10:46