Jump to content

It makes it hard to read code if you use the same word for type definition and variable with just...


G+_Stephen Hart
 Share

Recommended Posts

It makes it hard to read code if you use the same word for type definition and variable with just capitalization differences, like with the line

Person person;

 

It is easier to have 2 different words so I can push a different meaning for each of them into my mind when reading later code. When they are spelled with the exact same letters, my brain just won't do that. 

Link to comment
Share on other sites

Many languages have conventions that use case for different things: many OO languages, as mentioned, capitalize class names. C programs distinguish macros from functions by putting macros in all caps. JavaScript programmers capitalize factory functions to help ensure their proper use. Go capitalizes public methods. It's definitely something developers have to get used to.

Link to comment
Share on other sites

If you're familiar with "Camel Case" I'm sure you're familiar with Hungarian. But, even though this is kind of off topic, something E. Shanzer said in the Triangulation episode I posted made Polish Notation easy to understand. He said that an operator is just another function. Which means that 2 + 3 + 4 in Polish Notation, + + 2 3 4, can be thought of as Add(Add(2,3),4). Being someone who's used to nesting functions, I suddenly "got it."

Link to comment
Share on other sites

Oh, I  understand. Polish Notation is prefix, RPN is postfix and was popular with early computers because it's (a) a natural fit for stack-based machines and (b) it's actually an extension of the way cash registers work. For many years I was much faster using my RPN-based HP calculator than any sucky old TI.

 

To get back on subject: Hungarian Notation was primarily a Microsoft thing. The goal was (is) to embed information about a variable's type right in its name. The main limitations on that are that (a) it's only useful for strongly typed languages and (b) Us Linux coders believe that if the code was hard to write, it should be hard to read. ;-)

 

http://en.wikipedia.org/wiki/Hungarian_notation

Link to comment
Share on other sites

 Share

×
×
  • Create New...