Thread: Notation

  1. #1
    Registered User
    Join Date
    Jan 2007


    What naming convention and indent style do you use?

    I use Application Hungarian Notation (so that I dont have to look for the declarations to know the type) and K&R indent style because it looks the best and is easiest (too me at least).

  2. #2
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    I suggest you move out of Hungarian notation. The major flaw in my opinion is if you later change the variable type, you either have to change the variable name all over the code, or accept the fact you just broke your own notation by having a non conforming variable. There's also portability issues across programming languages or across the same programming language where typedefs or other type aliases mechanisms are being used. Hungarian notation, for instance never worked well in the presence of user defined objects (aka classes).

    I use no notation in particular. All my classes start with capital C. all variables are lower case with multiple word variables separated by an underscore. All function names are the same as variables, except for some member functions which are capitalized. And... i guess that's it.

    I use K&R with some variants. e.g. I don't open curly braces on if and for statements that are followed by one single line, or a namespace declaration never indents its contents. I just make sure the namespace closing bracer is followed by a single-line comment with the words namespace followed by the name of the namespace. There's a few other quirks here and there, but I try to keep it consistent.

    EDIT: Oh... all my private data members end in an underscore. My getters and setters (when I need them, are never prefixed by get or set. I simply "overload" the data member name, without the underscore.

    class CCar {
            int speed() { return speed_; }
            void speed(int x) { speed_ = x; }
            int speed_;
    Last edited by Mario F.; 01-10-2007 at 07:30 PM.
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Expression: Convert infix notation to postfix notation.
    By Nutshell in forum C Programming
    Replies: 7
    Last Post: 02-27-2010, 07:44 AM
  2. CamelCase VS Hungarian notation, which is better?
    By meili100 in forum C++ Programming
    Replies: 4
    Last Post: 04-22-2007, 09:31 PM
  3. I need help with RPN notation!!!
    By schnoor22 in forum C++ Programming
    Replies: 2
    Last Post: 04-09-2007, 05:12 PM
  4. polish notation calc problem
    By deedlit in forum C Programming
    Replies: 6
    Last Post: 06-14-2004, 10:17 PM
  5. hungarian notation
    By confuted in forum C++ Programming
    Replies: 2
    Last Post: 07-28-2003, 01:19 PM