vakkotaur: (computer)
[personal profile] vakkotaur


I've seen discussions, or rather arguments, about whether MixedCaseVariableNames are better or if underscore_linked_variable_names are better. I have dealt with both. From my Forth background, I rather prefer the MixedCaseVariableNames as one of the Forth tools I have results in printouts with underlines, which make underscores indistinguishable from spaces - this is a Bad Thing when trying to debug. Of course, in Forth I can use ~Variable-Names-With*Unusual-Characters-in-Them! if I am so inclined.

Now that my bias has been revealed, I'll address one of the notions of some of the underscore users. The idea is that say, this_is_a_test won't have the missing capital problem that ThisIsATest might if someone flubs and uses ThisIsaTest instead. This error could be found with a system that demands all variables be explicitly created. But not all systems are like that. Many are, or can be, quite lax and let the first instance of something substitute for an explicit declaration.

But the problem is not even that. The problem is that of case sensitivity. In an ideal system, case would be preserved, but not distinguished between. That is, if I make a variable named CustomerID the system editor won't go changing it on me to be customerid or CUSTOMERID but will leave it alone as CustomerID. But it will also accept CUSTOMERID and customerid and customerID and they will all point to the same information as CustomerID. Not that the programmer should go around not caring about case. Ideally each instance of the variable would look like all the other instances of the variable - but that's something the search-and-replace function of an editor can handle if need be.

"But that means you can't use each separately!" That's right. Which means I'd have to think up names that won't overlap in mental name-space and be confusing. It would require that I not obfuscate my code, at least not by abusing case.

Now, MiXedcAsevaARiabLeNAMe is something that does deserve to be editted out of any respectable program. Unlike MixedCaseVariableName, nothing is gained in readability by random capitalization. Rather, it just makes the programmer look like an idiot.

Date: 23 Feb 2005 00:56 (UTC)
From: [identity profile] foolscap001.livejournal.com
I wish that Algol 68 had been more successful. It has various sorts of "stropping" to let you distinguish reserved words and operators from identifiers, so that identifiers don't need to be all run together.

(love algol 68 | honk)

Date: 23 Feb 2005 12:52 (UTC)
From: [identity profile] jmaynard.livejournal.com
Yeah, but that, in practice, makes editing programs even tougher, and it comes from someone misreading the ALGOL 60 spec: that spec had all reserved words underlined, so he implemented the compiler to require that, and it just stuck. That wasn't the original intent. The underlining was there just to make the examples clearer.

Profile

vakkotaur: Centaur holding bow - cartoon (Default)
Vakkotaur

March 2024

S M T W T F S
     12
3 456789
10111213141516
17181920212223
24252627282930
31      

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated 6 March 2026 08:39
Powered by Dreamwidth Studios