Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Other Discussions
  3. The Weird and The Wonderful
  4. I don't care about your naming convention, just be consistent [modified]

I don't care about your naming convention, just be consistent [modified]

Scheduled Pinned Locked Moved The Weird and The Wonderful
21 Posts 10 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    wizardzz
    wrote on last edited by
    #1

    I was just given a project to rewrite, cleanup, and add features to. The first class I look at has these variables. It appears the original author liked to use almost every convention for naming variables, arbitrarily changing it up.

    private string ip_addr = "xx.xx.xx.xx";
    private int _port = 2000;
    public int countQuotesReceived = 0, countQuotesCreated = 0;
    public bool _connected = false;
    public bool _initialized = false;
    public bool BroadCast = false, ResetHighsLows = false;
    public bool reconnecting = false;

    modified on Monday, January 17, 2011 4:35 PM

    OriginalGriffO B L 3 Replies Last reply
    0
    • W wizardzz

      I was just given a project to rewrite, cleanup, and add features to. The first class I look at has these variables. It appears the original author liked to use almost every convention for naming variables, arbitrarily changing it up.

      private string ip_addr = "xx.xx.xx.xx";
      private int _port = 2000;
      public int countQuotesReceived = 0, countQuotesCreated = 0;
      public bool _connected = false;
      public bool _initialized = false;
      public bool BroadCast = false, ResetHighsLows = false;
      public bool reconnecting = false;

      modified on Monday, January 17, 2011 4:35 PM

      OriginalGriffO Offline
      OriginalGriffO Offline
      OriginalGriff
      wrote on last edited by
      #2

      Where's Hungarian?

      Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.

      "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
      "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

      W N 2 Replies Last reply
      0
      • OriginalGriffO OriginalGriff

        Where's Hungarian?

        Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.

        W Offline
        W Offline
        wizardzz
        wrote on last edited by
        #3

        Here it is. Note, it's on a public variable, too. I should have posted more the first time. This is a copy/paste, so this is his spacing, and his ordering of the access levels:

            public DataTable dtQuotes;
        
            private QuoteHub \_QuoteHub;
        
            private string ip\_addr = "xx.xx.xx.xxx";
            private int \_port = 2000;
            public int countQuotesReceived = 0, countQuotesCreated = 0;
            public bool \_connected = false;
            public bool \_initialized = false;
            public bool BroadCast = false, ResetHighsLows = false;
            public bool reconnecting = false;
        

        modified on Monday, January 17, 2011 4:35 PM

        OriginalGriffO Y 2 Replies Last reply
        0
        • W wizardzz

          Here it is. Note, it's on a public variable, too. I should have posted more the first time. This is a copy/paste, so this is his spacing, and his ordering of the access levels:

              public DataTable dtQuotes;
          
              private QuoteHub \_QuoteHub;
          
              private string ip\_addr = "xx.xx.xx.xxx";
              private int \_port = 2000;
              public int countQuotesReceived = 0, countQuotesCreated = 0;
              public bool \_connected = false;
              public bool \_initialized = false;
              public bool BroadCast = false, ResetHighsLows = false;
              public bool reconnecting = false;
          

          modified on Monday, January 17, 2011 4:35 PM

          OriginalGriffO Offline
          OriginalGriffO Offline
          OriginalGriff
          wrote on last edited by
          #4

          So, it should be "m_dtQuotes" anyway. :laugh: Make his wages as consistent as his naming conventions. Bet he falls into line quickly.

          Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.

          "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
          "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

          W 1 Reply Last reply
          0
          • W wizardzz

            Here it is. Note, it's on a public variable, too. I should have posted more the first time. This is a copy/paste, so this is his spacing, and his ordering of the access levels:

                public DataTable dtQuotes;
            
                private QuoteHub \_QuoteHub;
            
                private string ip\_addr = "xx.xx.xx.xxx";
                private int \_port = 2000;
                public int countQuotesReceived = 0, countQuotesCreated = 0;
                public bool \_connected = false;
                public bool \_initialized = false;
                public bool BroadCast = false, ResetHighsLows = false;
                public bool reconnecting = false;
            

            modified on Monday, January 17, 2011 4:35 PM

            Y Offline
            Y Offline
            Yusuf
            wrote on last edited by
            #5

            By Hungarian @OriginalGriff is looking for m_

            Yusuf May I help you?

            W OriginalGriffO 2 Replies Last reply
            0
            • W wizardzz

              I was just given a project to rewrite, cleanup, and add features to. The first class I look at has these variables. It appears the original author liked to use almost every convention for naming variables, arbitrarily changing it up.

              private string ip_addr = "xx.xx.xx.xx";
              private int _port = 2000;
              public int countQuotesReceived = 0, countQuotesCreated = 0;
              public bool _connected = false;
              public bool _initialized = false;
              public bool BroadCast = false, ResetHighsLows = false;
              public bool reconnecting = false;

              modified on Monday, January 17, 2011 4:35 PM

              B Offline
              B Offline
              BillW33
              wrote on last edited by
              #6

              They say variety is the spice of life ;) There is such a thing as taking it too far, however. :omg:

              Just because the code works, it doesn't mean that it is good code.

              1 Reply Last reply
              0
              • Y Yusuf

                By Hungarian @OriginalGriff is looking for m_

                Yusuf May I help you?

                W Offline
                W Offline
                wizardzz
                wrote on last edited by
                #7

                According to Microsoft and Wikipedia it is still Hungarian notation without the m_, Hungarian notation just means the type is in the name. I'll keep looking for a variable that includes the scope with Hungarian notation, though http://en.wikipedia.org/wiki/Hungarian_notation[^] http://msdn.microsoft.com/en-us/library/aa260976%28v=vs.60%29.aspx[^]

                1 Reply Last reply
                0
                • OriginalGriffO OriginalGriff

                  So, it should be "m_dtQuotes" anyway. :laugh: Make his wages as consistent as his naming conventions. Bet he falls into line quickly.

                  Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.

                  W Offline
                  W Offline
                  wizardzz
                  wrote on last edited by
                  #8

                  Well, he's no longer at the company, not sure why ;). I was hired to fill his position.

                  1 Reply Last reply
                  0
                  • Y Yusuf

                    By Hungarian @OriginalGriff is looking for m_

                    Yusuf May I help you?

                    OriginalGriffO Offline
                    OriginalGriffO Offline
                    OriginalGriff
                    wrote on last edited by
                    #9

                    By Hungarian I mean the type is prefixed onto the variable name as in iCount, lpszName etc. The "m_", "p_", g_" etc. metaprefix indates the scope: Member of class, function parameter, global and so on. Once upon a time we thought this was a good idea! But then incremental compilation meant we could go back to readable, pronounceable variable names. (I'm waiting for the next generation retrospective on naming, when we go back to a maximum of six characters, and the first character defines it as a integer if it is 'i' to 'n' so you don't even have to declare them...)

                    Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.

                    "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
                    "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

                    Y R R 3 Replies Last reply
                    0
                    • OriginalGriffO OriginalGriff

                      By Hungarian I mean the type is prefixed onto the variable name as in iCount, lpszName etc. The "m_", "p_", g_" etc. metaprefix indates the scope: Member of class, function parameter, global and so on. Once upon a time we thought this was a good idea! But then incremental compilation meant we could go back to readable, pronounceable variable names. (I'm waiting for the next generation retrospective on naming, when we go back to a maximum of six characters, and the first character defines it as a integer if it is 'i' to 'n' so you don't even have to declare them...)

                      Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.

                      Y Offline
                      Y Offline
                      Yusuf
                      wrote on last edited by
                      #10

                      OriginalGriff wrote:

                      (I'm waiting for the next generation retrospective on naming, when we go back to a maximum of six characters, and the first character defines it as a integer if it is 'i' to 'n' so you don't even have to declare them...)

                      Good idea. Let us know when it is released :rolleyes: ;P

                      Yusuf May I help you?

                      1 Reply Last reply
                      0
                      • OriginalGriffO OriginalGriff

                        By Hungarian I mean the type is prefixed onto the variable name as in iCount, lpszName etc. The "m_", "p_", g_" etc. metaprefix indates the scope: Member of class, function parameter, global and so on. Once upon a time we thought this was a good idea! But then incremental compilation meant we could go back to readable, pronounceable variable names. (I'm waiting for the next generation retrospective on naming, when we go back to a maximum of six characters, and the first character defines it as a integer if it is 'i' to 'n' so you don't even have to declare them...)

                        Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.

                        R Offline
                        R Offline
                        rentzk
                        wrote on last edited by
                        #11

                        Don't remind me. I was downgraded by a professor for defining variables that just happened to start with i and j. Apparently, Pascal teaches you bad habits :~

                        RaviBeeR 1 Reply Last reply
                        0
                        • R rentzk

                          Don't remind me. I was downgraded by a professor for defining variables that just happened to start with i and j. Apparently, Pascal teaches you bad habits :~

                          RaviBeeR Offline
                          RaviBeeR Offline
                          RaviBee
                          wrote on last edited by
                          #12

                          rentzk wrote:

                          Apparently, Pascal teaches you bad habits

                          What do variable names like i and j have to with Pascal? :confused: /ravi

                          My new year resolution: 2048 x 1536 Home | Articles | My .NET bits | Freeware ravib(at)ravib(dot)com

                          OriginalGriffO R 2 Replies Last reply
                          0
                          • RaviBeeR RaviBee

                            rentzk wrote:

                            Apparently, Pascal teaches you bad habits

                            What do variable names like i and j have to with Pascal? :confused: /ravi

                            My new year resolution: 2048 x 1536 Home | Articles | My .NET bits | Freeware ravib(at)ravib(dot)com

                            OriginalGriffO Offline
                            OriginalGriffO Offline
                            OriginalGriff
                            wrote on last edited by
                            #13

                            Nothing that I remember: 'i' through 'n' inclusive being default declaration for integer, and the six character limit were FORTRAN.

                            Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.

                            "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
                            "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

                            1 Reply Last reply
                            0
                            • RaviBeeR RaviBee

                              rentzk wrote:

                              Apparently, Pascal teaches you bad habits

                              What do variable names like i and j have to with Pascal? :confused: /ravi

                              My new year resolution: 2048 x 1536 Home | Articles | My .NET bits | Freeware ravib(at)ravib(dot)com

                              R Offline
                              R Offline
                              rentzk
                              wrote on last edited by
                              #14

                              Sorry, I was in a bit of a hurry. Pascal was where I was taught to always define my variables. This was not appreciated by a very old school instructor who taught the FORTRAN class. Fortunately, the Pascal lessons stuck with me a lot better than the FORTRAN ones.

                              1 Reply Last reply
                              0
                              • OriginalGriffO OriginalGriff

                                Where's Hungarian?

                                Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.

                                N Offline
                                N Offline
                                Nagy Vilmos
                                wrote on last edited by
                                #15

                                You called?


                                Panic, Chaos, Destruction. My work here is done. or "Drink. Get drunk. Fall over." - P O'H OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre

                                OriginalGriffO 1 Reply Last reply
                                0
                                • N Nagy Vilmos

                                  You called?


                                  Panic, Chaos, Destruction. My work here is done. or "Drink. Get drunk. Fall over." - P O'H OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre

                                  OriginalGriffO Offline
                                  OriginalGriffO Offline
                                  OriginalGriff
                                  wrote on last edited by
                                  #16

                                  No, not you - your name doesn't start with a lower case letter, and is quite pronounceable. :laugh:

                                  Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.

                                  "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
                                  "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

                                  J 1 Reply Last reply
                                  0
                                  • OriginalGriffO OriginalGriff

                                    By Hungarian I mean the type is prefixed onto the variable name as in iCount, lpszName etc. The "m_", "p_", g_" etc. metaprefix indates the scope: Member of class, function parameter, global and so on. Once upon a time we thought this was a good idea! But then incremental compilation meant we could go back to readable, pronounceable variable names. (I'm waiting for the next generation retrospective on naming, when we go back to a maximum of six characters, and the first character defines it as a integer if it is 'i' to 'n' so you don't even have to declare them...)

                                    Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.

                                    R Offline
                                    R Offline
                                    Rob Grainger
                                    wrote on last edited by
                                    #17

                                    The m_, g_ etc. prefixes are all later inventions MS added when they started writing MFC (I guess, that's the first usage I ever came across). You don't really need them in C as the only scopes are global, file and local.

                                    OriginalGriffO 1 Reply Last reply
                                    0
                                    • R Rob Grainger

                                      The m_, g_ etc. prefixes are all later inventions MS added when they started writing MFC (I guess, that's the first usage I ever came across). You don't really need them in C as the only scopes are global, file and local.

                                      OriginalGriffO Offline
                                      OriginalGriffO Offline
                                      OriginalGriff
                                      wrote on last edited by
                                      #18

                                      That's where I first met Hungarian notation. The only problem is I still use a bastardized version of it: tb for TextBox, but for Button, dgv for DateGridView... One day, I must try to make a clean break! :laugh:

                                      Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.

                                      "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
                                      "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

                                      1 Reply Last reply
                                      0
                                      • W wizardzz

                                        I was just given a project to rewrite, cleanup, and add features to. The first class I look at has these variables. It appears the original author liked to use almost every convention for naming variables, arbitrarily changing it up.

                                        private string ip_addr = "xx.xx.xx.xx";
                                        private int _port = 2000;
                                        public int countQuotesReceived = 0, countQuotesCreated = 0;
                                        public bool _connected = false;
                                        public bool _initialized = false;
                                        public bool BroadCast = false, ResetHighsLows = false;
                                        public bool reconnecting = false;

                                        modified on Monday, January 17, 2011 4:35 PM

                                        L Offline
                                        L Offline
                                        Lutoslaw
                                        wrote on last edited by
                                        #19

                                        Maybe every piece of code comes from another on-line tutorial where various naming conventions were used. Better not to change anything if it works you know.

                                        Greetings - Jacek

                                        W 1 Reply Last reply
                                        0
                                        • L Lutoslaw

                                          Maybe every piece of code comes from another on-line tutorial where various naming conventions were used. Better not to change anything if it works you know.

                                          Greetings - Jacek

                                          W Offline
                                          W Offline
                                          wizardzz
                                          wrote on last edited by
                                          #20

                                          That's more than likely.

                                          1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • World
                                          • Users
                                          • Groups