Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

Just wondering if anybody has a good convention to follow in this corner-corner-corner case. I really use Java but figured the C# folks might have some good insight too.

Say I am trying to name a class where two consecutive words in the class name are numeric (note that the same question could asked about identifier names). Can't get a great example, but think of something like "IEEE 802 16 bit value".

Combining consecutive acronyms is doable if you accept classnames such as HttpUrlConnection. But it seriously makes me throw up a little to think of naming the class IEEE80216BitValue. If I had to pick, I'd say that's even worse than IEEE802_16BitValue which looks like a bad mistake. For small numbers, I'd consider IEEE802SixteenBitValue but that doesn't scale that well.

Anyone out there have a convention? Seems like Microsoft's naming guidelines are the only ones that describe acronym naming in enough detail to get the job done, but nobody has addressed numbers in classnames.

share|improve this question

migrated from stackoverflow.com Mar 20 '12 at 18:17

This question came from our site for professional and enthusiast programmers.

1  
Probably not on topic on SO, still an interesting question. –  CodesInChaos Mar 20 '12 at 18:13
3  
I'd probably go with _ if necessary. Everything else I can think of (except reordering where possible) is even worse. In your example Ieee802Value16Bit is what I'd do in your example. –  CodesInChaos Mar 20 '12 at 18:14
    
Oops. I figured with the existence of a naming-conventions tag, it was close enough to on-topic to at least ask. :) –  Rob I Mar 20 '12 at 18:14
    
Simple: do not use camel case. Today there is no reason for it because linkers are not restricted to 6 characters in external names. I eschew embedded capital letters in names; to my prose-oriented eyes, they are too awkward to read comfortably. They jangle like bad typography. - Rob Pike, "Notes on Programming in C" –  Kaz Mar 20 '12 at 18:15
4  
@Kaz We're talking about C#/Java here. Also beauty is in the eye of the beholder. Personally I think _ is uglier than camelCase or PascalCase. –  CodesInChaos Mar 20 '12 at 18:16

3 Answers 3

up vote 9 down vote accepted

I'd figure out a new variable name instead of trying to figure out what naming convention to use for a double-number variable

That said, if I absolutely HAD to use a double-number in my variable name, and I couldn't rearrange the words/numbers to come up with something reasonable, and absolutely no other name would make sense, I would use an _ between the numbers

...

Actually I take it back, I would just figure out a new variable name :)

share|improve this answer
7  
+1 We make network equipment at work, so one would think standard-related class names come up a lot, but I don't remember having this issue, so I looked through our code base. Instead of prefixes like IEEE802, we use esoteric words like "Ethernet" :-) –  Karl Bielefeldt Mar 20 '12 at 19:26
    
What about SHA-512/256 or SHA3-256? I'm having a hard time coming up with names that don't contain an _. –  CodesInChaos Dec 6 '13 at 14:16

I have used some letter to delimit consecutive numbers. For me it would be Ieee802x16bit (not IEEE802x16bit). I think it is less distracting then a lone underbar in the middle of a jungle of letters and digits.

share|improve this answer

I'd personally go for the underscore route e.g. IEEE_802_16_BitValue. Currently dealing with modelling some CPU architectures, this Q was good timing :-)

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.