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. The Lounge
  3. I'll see your curly braces & raise you a variable naming convention

I'll see your curly braces & raise you a variable naming convention

Scheduled Pinned Locked Moved The Lounge
androidcsharpc++javascriptswift
36 Posts 15 Posters 0 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.
  • raddevusR Offline
    raddevusR Offline
    raddevus
    wrote on last edited by
    #1

    So which type of convention do you use when naming variables with multiple words? * camelCase * PascalCase * snake_case // Rust requires this for variable, function and struct member names and the compiler will warn (gripe at you) if you use other. I really like Rust, but this drives me crazy because it is YAC (Yet Another Convention) Back in C++ & C# I always used PascalCase Then in recent years JavaScript has effected my mind and I use a lot of camelCase these days. Kotlin (Android dev) & Swift (iOS dev) seem to use camelCase too. So it becoming kind of a standard. How about you? See more here[^].

    OriginalGriffO D Mircea NeacsuM Greg UtasG P 13 Replies Last reply
    0
    • raddevusR raddevus

      So which type of convention do you use when naming variables with multiple words? * camelCase * PascalCase * snake_case // Rust requires this for variable, function and struct member names and the compiler will warn (gripe at you) if you use other. I really like Rust, but this drives me crazy because it is YAC (Yet Another Convention) Back in C++ & C# I always used PascalCase Then in recent years JavaScript has effected my mind and I use a lot of camelCase these days. Kotlin (Android dev) & Swift (iOS dev) seem to use camelCase too. So it becoming kind of a standard. How about you? See more here[^].

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

      Depends. Mostly camelCase for local and parameter variables, PascalCase for properties and methods, with a little Hungarian thrown in for contols: butOK, tbUsername, ...

      "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 AntiTwitter: @DalekDave is now a follower!

      "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

      raddevusR D 2 Replies Last reply
      0
      • raddevusR raddevus

        So which type of convention do you use when naming variables with multiple words? * camelCase * PascalCase * snake_case // Rust requires this for variable, function and struct member names and the compiler will warn (gripe at you) if you use other. I really like Rust, but this drives me crazy because it is YAC (Yet Another Convention) Back in C++ & C# I always used PascalCase Then in recent years JavaScript has effected my mind and I use a lot of camelCase these days. Kotlin (Android dev) & Swift (iOS dev) seem to use camelCase too. So it becoming kind of a standard. How about you? See more here[^].

        D Offline
        D Offline
        den2k88
        wrote on last edited by
        #3

        camelCase for static / private / local members, PascalCase for public members. Globals, where needed, are g_CamelCase.

        GCS/GE d--(d) s-/+ a C+++ U+++ P-- L+@ E-- W+++ N+ o+ K- w+++ O? M-- V? PS+ PE Y+ PGP t+ 5? X R+++ tv-- b+(+++) DI+++ D++ G e++ h--- r+++ y+++*      Weapons extension: ma- k++ F+2 X

        1 Reply Last reply
        0
        • OriginalGriffO OriginalGriff

          Depends. Mostly camelCase for local and parameter variables, PascalCase for properties and methods, with a little Hungarian thrown in for contols: butOK, tbUsername, ...

          "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 AntiTwitter: @DalekDave is now a follower!

          raddevusR Offline
          raddevusR Offline
          raddevus
          wrote on last edited by
          #4

          OriginalGriff wrote:

          with a little Hungarian thrown in

          tut tut... I'll have to give you 5 demerits for that.* :rolleyes: *Had to say it, because I was a huge Hungarian-follower for so many years (remember all them Windows API calls?) and then they rugged us telling us to stop it. I was damaged from that. :laugh:

          1 Reply Last reply
          0
          • OriginalGriffO OriginalGriff

            Depends. Mostly camelCase for local and parameter variables, PascalCase for properties and methods, with a little Hungarian thrown in for contols: butOK, tbUsername, ...

            "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 AntiTwitter: @DalekDave is now a follower!

            D Offline
            D Offline
            den2k88
            wrote on last edited by
            #5

            OriginalGriff wrote:

            with a little Hungarian thrown in for contols: butOK, tbUsername

            Hush, it's ok, VisualBasic will hurt you no more...

            GCS/GE d--(d) s-/+ a C+++ U+++ P-- L+@ E-- W+++ N+ o+ K- w+++ O? M-- V? PS+ PE Y+ PGP t+ 5? X R+++ tv-- b+(+++) DI+++ D++ G e++ h--- r+++ y+++*      Weapons extension: ma- k++ F+2 X

            1 Reply Last reply
            0
            • raddevusR raddevus

              So which type of convention do you use when naming variables with multiple words? * camelCase * PascalCase * snake_case // Rust requires this for variable, function and struct member names and the compiler will warn (gripe at you) if you use other. I really like Rust, but this drives me crazy because it is YAC (Yet Another Convention) Back in C++ & C# I always used PascalCase Then in recent years JavaScript has effected my mind and I use a lot of camelCase these days. Kotlin (Android dev) & Swift (iOS dev) seem to use camelCase too. So it becoming kind of a standard. How about you? See more here[^].

              Mircea NeacsuM Offline
              Mircea NeacsuM Offline
              Mircea Neacsu
              wrote on last edited by
              #6

              Programs should be read as books. What would you prefer, aBookThatIsTypesetInLongWordsAlmostLikeGerman, or a_more_relaxed_one_that_leaves_spaces_between_words? PS: Is it St. Sterile de Bates Day today?

              Mircea

              D raddevusR J 3 Replies Last reply
              0
              • Mircea NeacsuM Mircea Neacsu

                Programs should be read as books. What would you prefer, aBookThatIsTypesetInLongWordsAlmostLikeGerman, or a_more_relaxed_one_that_leaves_spaces_between_words? PS: Is it St. Sterile de Bates Day today?

                Mircea

                D Offline
                D Offline
                den2k88
                wrote on last edited by
                #7

                Writing snake_case variables is annoying, freaking underscore needs a double keypress after every word. I'd love it if it wasn't so cumbersome.

                GCS/GE d--(d) s-/+ a C+++ U+++ P-- L+@ E-- W+++ N+ o+ K- w+++ O? M-- V? PS+ PE Y+ PGP t+ 5? X R+++ tv-- b+(+++) DI+++ D++ G e++ h--- r+++ y+++*      Weapons extension: ma- k++ F+2 X

                Mircea NeacsuM 1 Reply Last reply
                0
                • D den2k88

                  Writing snake_case variables is annoying, freaking underscore needs a double keypress after every word. I'd love it if it wasn't so cumbersome.

                  GCS/GE d--(d) s-/+ a C+++ U+++ P-- L+@ E-- W+++ N+ o+ K- w+++ O? M-- V? PS+ PE Y+ PGP t+ 5? X R+++ tv-- b+(+++) DI+++ D++ G e++ h--- r+++ y+++*      Weapons extension: ma- k++ F+2 X

                  Mircea NeacsuM Offline
                  Mircea NeacsuM Offline
                  Mircea Neacsu
                  wrote on last edited by
                  #8

                  Hmm, on my keyboard Caps also need a double keypress ;P

                  Mircea

                  D 1 Reply Last reply
                  0
                  • raddevusR raddevus

                    So which type of convention do you use when naming variables with multiple words? * camelCase * PascalCase * snake_case // Rust requires this for variable, function and struct member names and the compiler will warn (gripe at you) if you use other. I really like Rust, but this drives me crazy because it is YAC (Yet Another Convention) Back in C++ & C# I always used PascalCase Then in recent years JavaScript has effected my mind and I use a lot of camelCase these days. Kotlin (Android dev) & Swift (iOS dev) seem to use camelCase too. So it becoming kind of a standard. How about you? See more here[^].

                    Greg UtasG Offline
                    Greg UtasG Offline
                    Greg Utas
                    wrote on last edited by
                    #9

                    Usually PascalCase, but camelCase for member data and locals.

                    Robust Services Core | Software Techniques for Lemmings | Articles
                    The fox knows many things, but the hedgehog knows one big thing.

                    <p><a href="https://github.com/GregUtas/robust-services-core/blob/master/README.md">Robust Services Core</a>
                    <em>The fox knows many things, but the hedgehog knows one big thing.</em></p>

                    1 Reply Last reply
                    0
                    • Mircea NeacsuM Mircea Neacsu

                      Hmm, on my keyboard Caps also need a double keypress ;P

                      Mircea

                      D Offline
                      D Offline
                      den2k88
                      wrote on last edited by
                      #10

                      True that, but one hand remains on the letter portion of the keyboard. I find it easier, also more compact. Though snake_case helps understanding.

                      GCS/GE d--(d) s-/+ a C+++ U+++ P-- L+@ E-- W+++ N+ o+ K- w+++ O? M-- V? PS+ PE Y+ PGP t+ 5? X R+++ tv-- b+(+++) DI+++ D++ G e++ h--- r+++ y+++*      Weapons extension: ma- k++ F+2 X

                      Mircea NeacsuM 1 Reply Last reply
                      0
                      • D den2k88

                        True that, but one hand remains on the letter portion of the keyboard. I find it easier, also more compact. Though snake_case helps understanding.

                        GCS/GE d--(d) s-/+ a C+++ U+++ P-- L+@ E-- W+++ N+ o+ K- w+++ O? M-- V? PS+ PE Y+ PGP t+ 5? X R+++ tv-- b+(+++) DI+++ D++ G e++ h--- r+++ y+++*      Weapons extension: ma- k++ F+2 X

                        Mircea NeacsuM Offline
                        Mircea NeacsuM Offline
                        Mircea Neacsu
                        wrote on last edited by
                        #11

                        I know I'm not going to win this argument but on my keyboard, underscore is right above the P. I promise I'm not going to continue this argument :laugh:

                        Mircea

                        T 1 Reply Last reply
                        0
                        • raddevusR raddevus

                          So which type of convention do you use when naming variables with multiple words? * camelCase * PascalCase * snake_case // Rust requires this for variable, function and struct member names and the compiler will warn (gripe at you) if you use other. I really like Rust, but this drives me crazy because it is YAC (Yet Another Convention) Back in C++ & C# I always used PascalCase Then in recent years JavaScript has effected my mind and I use a lot of camelCase these days. Kotlin (Android dev) & Swift (iOS dev) seem to use camelCase too. So it becoming kind of a standard. How about you? See more here[^].

                          P Online
                          P Online
                          PIEBALDconsult
                          wrote on last edited by
                          #12

                          I reject the premise of the question.

                          raddevusR 1 Reply Last reply
                          0
                          • raddevusR raddevus

                            So which type of convention do you use when naming variables with multiple words? * camelCase * PascalCase * snake_case // Rust requires this for variable, function and struct member names and the compiler will warn (gripe at you) if you use other. I really like Rust, but this drives me crazy because it is YAC (Yet Another Convention) Back in C++ & C# I always used PascalCase Then in recent years JavaScript has effected my mind and I use a lot of camelCase these days. Kotlin (Android dev) & Swift (iOS dev) seem to use camelCase too. So it becoming kind of a standard. How about you? See more here[^].

                            Mike HankeyM Offline
                            Mike HankeyM Offline
                            Mike Hankey
                            wrote on last edited by
                            #13

                            In[Case]

                            PartsBin an Electronics Part Organizer - An updated version available! JaxCoder.com

                            1 Reply Last reply
                            0
                            • Mircea NeacsuM Mircea Neacsu

                              Programs should be read as books. What would you prefer, aBookThatIsTypesetInLongWordsAlmostLikeGerman, or a_more_relaxed_one_that_leaves_spaces_between_words? PS: Is it St. Sterile de Bates Day today?

                              Mircea

                              raddevusR Offline
                              raddevusR Offline
                              raddevus
                              wrote on last edited by
                              #14

                              That's actually a very good point. It's probably just 1. the jarring nature of it (diff from past) 2. all those extra characters (_) You've really made a great point here though & you've got me thinking. :thumbsup:

                              1 Reply Last reply
                              0
                              • P PIEBALDconsult

                                I reject the premise of the question.

                                raddevusR Offline
                                raddevusR Offline
                                raddevus
                                wrote on last edited by
                                #15

                                PIEBALDconsult wrote:

                                I reject the premise of the question.

                                I like it!!! It is baseless. Reminds me of an old great quote:

                                Benjamin Franklin (the dude on the $100USD bill)

                                "Your argument is sound! Nothing but sound!"

                                :laugh:

                                1 Reply Last reply
                                0
                                • raddevusR raddevus

                                  So which type of convention do you use when naming variables with multiple words? * camelCase * PascalCase * snake_case // Rust requires this for variable, function and struct member names and the compiler will warn (gripe at you) if you use other. I really like Rust, but this drives me crazy because it is YAC (Yet Another Convention) Back in C++ & C# I always used PascalCase Then in recent years JavaScript has effected my mind and I use a lot of camelCase these days. Kotlin (Android dev) & Swift (iOS dev) seem to use camelCase too. So it becoming kind of a standard. How about you? See more here[^].

                                  R Offline
                                  R Offline
                                  Ron Anders
                                  wrote on last edited by
                                  #16

                                  PascaleCase

                                  1 Reply Last reply
                                  0
                                  • raddevusR raddevus

                                    So which type of convention do you use when naming variables with multiple words? * camelCase * PascalCase * snake_case // Rust requires this for variable, function and struct member names and the compiler will warn (gripe at you) if you use other. I really like Rust, but this drives me crazy because it is YAC (Yet Another Convention) Back in C++ & C# I always used PascalCase Then in recent years JavaScript has effected my mind and I use a lot of camelCase these days. Kotlin (Android dev) & Swift (iOS dev) seem to use camelCase too. So it becoming kind of a standard. How about you? See more here[^].

                                    T Offline
                                    T Offline
                                    trønderen
                                    wrote on last edited by
                                    #17

                                    In my first 10-15 years of programming, hardcopy printouts were still common. Both my university and my first employer used a printer model placing the underscore so low that it almost hit the top of the characters on the line below; you certainly didn't see it as tying two characters together. In a listing, a name with underscores looked like several space separated words. For variables starting / ending with an underscore, the underscore was easily overlooked. This could at times be really confusing. So I came to strongly dislike underscores in identifiers. If you really wanted to underscore a text line for emphasis, like in a header, these printers were fine - they didn't clutter up the text. Other printers, placing the underscore at the character baseline, were not suitable for underscoring. E.g. an underscored h would be very similar to a b, an underscored n was close to an o. So for emphasizing text, our printers were great, but not for underscore used as a printable character in an identifier.

                                    raddevusR 1 Reply Last reply
                                    0
                                    • raddevusR raddevus

                                      So which type of convention do you use when naming variables with multiple words? * camelCase * PascalCase * snake_case // Rust requires this for variable, function and struct member names and the compiler will warn (gripe at you) if you use other. I really like Rust, but this drives me crazy because it is YAC (Yet Another Convention) Back in C++ & C# I always used PascalCase Then in recent years JavaScript has effected my mind and I use a lot of camelCase these days. Kotlin (Android dev) & Swift (iOS dev) seem to use camelCase too. So it becoming kind of a standard. How about you? See more here[^].

                                      honey the codewitchH Offline
                                      honey the codewitchH Offline
                                      honey the codewitch
                                      wrote on last edited by
                                      #18

                                      I use pascal case in .NET, camel case in JS, and snake case in my libraries in C++.

                                      To err is human. Fortune favors the monsters.

                                      raddevusR 1 Reply Last reply
                                      0
                                      • raddevusR raddevus

                                        So which type of convention do you use when naming variables with multiple words? * camelCase * PascalCase * snake_case // Rust requires this for variable, function and struct member names and the compiler will warn (gripe at you) if you use other. I really like Rust, but this drives me crazy because it is YAC (Yet Another Convention) Back in C++ & C# I always used PascalCase Then in recent years JavaScript has effected my mind and I use a lot of camelCase these days. Kotlin (Android dev) & Swift (iOS dev) seem to use camelCase too. So it becoming kind of a standard. How about you? See more here[^].

                                        S Offline
                                        S Offline
                                        Slacker007
                                        wrote on last edited by
                                        #19

                                        I pretty much do whatever strikes my fancy at the moment, throwing structure, conventions, and consistency to the wind. I find that adopting a care-free attitude to coding makes for a more interesting and fun time while testing and debugging my code in Production.

                                        raddevusR 1 Reply Last reply
                                        0
                                        • Mircea NeacsuM Mircea Neacsu

                                          I know I'm not going to win this argument but on my keyboard, underscore is right above the P. I promise I'm not going to continue this argument :laugh:

                                          Mircea

                                          T Offline
                                          T Offline
                                          trønderen
                                          wrote on last edited by
                                          #20

                                          Another reason that made me dislike underscores (the the first one is hardcopy readability): Although you are right about upper case also being a double stroke, both the shift and the letter have identical positions on all keyboards, and you can keep your hands in the same position (as long as you have learned to use your left pinky for the shift key). If you switch between different keyboards - especially keyboards adapted to different languages - punctuation and special characters such as underscore jumps all over the place. It took a few years to define a Norwegian standard placement for all those new characters that came with PCs, unknown on traditional typewriters, so if I dig up my oldest keyboards, even on Norwegian keyboards, they jump around. Using a Norwegian keyboard at home, a US English one at the office, and sometimes some machinery with its own keyboard layout, can be very frustrating. Nowadays, on a Norwegian keyboard, underscore is shift-hyphen, the rightmost key in the bottom row, next to right shift. You have to move your right hand three-quarters off the keyboard to hit it. (That also goes for hyphen, even if it is un-shifted.)

                                          Mircea NeacsuM 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