G+_Stephen Hart Posted April 17, 2015 Share Posted April 17, 2015 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 More sharing options...
G+_Michael Heinz Posted April 17, 2015 Share Posted April 17, 2015 Unfortunately the use of capitalization to differentiate types and classes from variables is a standard practice in the industry. If you do any amount of coding you're going to see that quite a lot. Link to comment Share on other sites More sharing options...
G+_Darryl Medley Posted April 18, 2015 Share Posted April 18, 2015 I agree Stephen. I normally work with a case-insensitive language (Delphi / Object Pascal) so we can't just use capitalization differences for names. Instead we use meaningful prefixes which I think is a much better "standard practice." Link to comment Share on other sites More sharing options...
G+_Lee Crocker Posted April 18, 2015 Share Posted April 18, 2015 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 More sharing options...
G+_Stephen Hart Posted April 18, 2015 Author Share Posted April 18, 2015 It isn't capitalization by itself, it is using the same word twice inside one function with only capitalization to make the 2 uses different. Link to comment Share on other sites More sharing options...
G+_Michael Heinz Posted April 18, 2015 Share Posted April 18, 2015 Oh, I do understand. My personal preferences is to add "_t" to the ends of type definitions for just that reason. Wait till you encounter "Camel Case". Link to comment Share on other sites More sharing options...
G+_Darryl Medley Posted April 22, 2015 Share Posted April 22, 2015 Does anyone out there still use Hungarian notation? Link to comment Share on other sites More sharing options...
G+_Michael Heinz Posted April 23, 2015 Share Posted April 23, 2015 Is that like Reverse Polish Notation? Link to comment Share on other sites More sharing options...
G+_Darryl Medley Posted April 23, 2015 Share Posted April 23, 2015 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 More sharing options...
G+_Michael Heinz Posted April 23, 2015 Share Posted April 23, 2015 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 More sharing options...
Recommended Posts