View Poll Results: Which do you use

Voters
35. You may not vote on this poll
  • char* name;

    10 28.57%
  • char *name;

    21 60.00%
  • char * name;

    4 11.43%
  • Other (plz post)

    0 0%

Which do you use?

This is a discussion on Which do you use? within the A Brief History of Cprogramming.com forums, part of the Community Boards category; well I usually do my variables (within a class) one per line but not the way adrianxw means. It's more ...

  1. #16
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    well I usually do my variables (within a class) one per line but not the way adrianxw means. It's more like this:

    Code:
    class Blah
       {
       public:
    
          int
             m_x,
             m_y,
             m_z;
    
          char
             *m_ptr,
             m_str[256],
             m_singlechar;
       }
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

  2. #17
    People Love Me
    Join Date
    Jan 2003
    Posts
    412

    Angry What???

    Am I the only one that uses
    Code:
    type * pVar;
    ?????

  3. #18
    Just one more wrong move. -KEN-'s Avatar
    Join Date
    Aug 2001
    Posts
    3,230
    >>Am I the only one that uses

    Yes - because nobody liks hungarian notation. To quote DavidP "A horse is a horse; there is no excuse for Hungarian Notation"

    Anyhow, I always use char *whatever. It's just how I learned it...I don't see the value in changing the way I do it if it's all aesthetics.

  4. #19
    I lurk
    Join Date
    Aug 2002
    Posts
    1,361

    Re: What???

    Originally posted by Krak
    Am I the only one that uses
    Code:
    type * pVar;
    ?????
    There's no need for hungarian notation in a type-safe language like C++
    It may have had a small place in C, but certainly not C++

  5. #20
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,831
    >>>
    To quote DavidP "A horse is a horse; there is no excuse for Hungarian Notation"
    <<<

    A "horse" is actually an "orse" handle...

    I believe there is a difference between Hungarian notation and calling pointers pSomething.

    The full Hungarian notation may have had a small use back in the dim and distant, but with todays IDE's, if I am unsure what something is declared as, I put my cursor on it and the IDE tells me, and offers to show me the declaration. Hungarian notation is inexcusable obfuscation.

    Frequently, however, I have an object and a pointer to the same object, Object and pObject. People will say that is Hungarian, but I would add, that I have been doing that since the late 70's, ergo, pre Hungarian, simple common sense.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  6. #21
    Just one more wrong move. -KEN-'s Avatar
    Join Date
    Aug 2001
    Posts
    3,230
    I'll concede - that point hadn't crossed my mind. You're right, even I do that if I have a pointer to the same data...

    >>A "horse" is actually an "orse" handle...

    Speaking of which, hWhatever is also something I do quite frequently thanks to Petzold

    As far as I can remember, that's about as deep into notation that I go...maybe I've left something out, but I doubt that...

    Oh, and every once-in-a-while I'll do the whole CClass thing...not all that often, though...

  7. #22
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,831
    My turn to confess, yes, I do call a handle to something an hSomething, but yes, that is also as far as I go.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  8. #23
    People Love Me
    Join Date
    Jan 2003
    Posts
    412
    Originally posted by -KEN-
    >>Am I the only one that uses

    Yes - because nobody liks hungarian notation. To quote DavidP "A horse is a horse; there is no excuse for Hungarian Notation"

    Anyhow, I always use char *whatever. It's just how I learned it...I don't see the value in changing the way I do it if it's all aesthetics.
    I just do it out of habit. When I started doing pointer crap, I just used:

    int * pPointer;

    I just feel more comfortable with that method for some reason.
    Hungarian notation? Meh. Screw that. I'm calling this "Krak Notation", since only I use it. Besides, it's not like it hurts anything.

  9. #24
    Registered User Commander's Avatar
    Join Date
    Sep 2001
    Posts
    804
    FILE *fp;

    always, i don;t feel comfortable putting it like FILE* fp; it just feels wierd!
    oh i'm sorry! i didn;t realize my fist was rushing to meet ur face!

    MSN :: commander_android@hotmail.com []*[]

  10. #25
    Peace
    Join Date
    Aug 2001
    Posts
    1,510
    char *pVar; actually... I learned it that way, and since I never declare multiple pointers on the same line or grouped, theres never confusion.

    >>... and one declaration per line - no confusion.

    Dito. Inside classes I will often group simular data such as FillYourBrain demonstrates:
    Code:
        int
             x,
             y,
             z;
    As for pVar: Always. I always identify pointers (for all the same reasons that have already been presented).
    "There's always another way"
    -lightatdawn (lightatdawn.cprogramming.com)

  11. #26
    Registered User Cela's Avatar
    Join Date
    Jan 2003
    Posts
    362
    Code:
    char *var;
    I use it because my data types won't associate with the lowly *, so it has to hang with my identifiers. Poor little guy, nobody ever considers how the operators feel, it's all about data types. My identifiers are cooler anyway, so the * is happier with them than with the cliquish data types :-)
    *Cela*

  12. #27
    Has a Masters in B.S.
    Join Date
    Aug 2001
    Posts
    2,267
    >My turn to confess, yes, I do call a handle to something an hSomething, but yes, that is also as far as I go.

    i for some reason, always prefix bools with b

    bool bThis, bThat;
    ADVISORY: This users posts are rated CP-MA, for Mature Audiences only.

  13. #28
    Peace
    Join Date
    Aug 2001
    Posts
    1,510
    Well, if we're all confessing our dirty little habits... My BOOLs are always fully uppercase. It just seems weird any other way. BOOL, TRUE, FALSE... It just works. *shrug* Though possibly I prefix by 'Is': IsCOMPLETE, etc.
    "There's always another way"
    -lightatdawn (lightatdawn.cprogramming.com)

  14. #29
    Has a Masters in B.S.
    Join Date
    Aug 2001
    Posts
    2,267
    but isn't that a little ugly? i only cap my defines, and i always suffix my typedefs with '_t'.

    and how's this for retarded!!!! i always prefix my enum type names with enum_ haha!!
    ADVISORY: This users posts are rated CP-MA, for Mature Audiences only.

  15. #30
    Peace
    Join Date
    Aug 2001
    Posts
    1,510
    >>but isn't that a little ugly? i only cap my defines

    I also cap my defines (in 99% of cases. There have been times when lowercase defines became appropriate). But an uppercase BOOL only seems right.

    BOOL IsComplete = TRUE;
    BOOL IsCOMPLETE = TRUE;

    It actually came to pass when I was writing some code for an older application and came across the rather unsual problem of strange results traced to passing a BOOL pointer to a function that accepted a bool pointer. The difference was not immediatly obvious, and it caused some confusion before realising that a BOOL is actually a 32-bit type. So I started differentiating my newly implemented BOOL variables by making them uppercase to avoid confusion when comparing them to the existing bools. The project was large and I got rather used to it...
    "There's always another way"
    -lightatdawn (lightatdawn.cprogramming.com)

Page 2 of 3 FirstFirst 123 LastLast
Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21