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. crap coding for myself. What variable names do you use?

crap coding for myself. What variable names do you use?

Scheduled Pinned Locked Moved The Lounge
question
36 Posts 30 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.
  • R rnbergren

    so frequently I find myself doing a proof of concept very short code that I am going to flush out later. Sometimes I even flush it. Pun intended. Anyway I frequently use variables like the following. astr - it is A String Temp table #ewww - because the data in the table is stinky at best. and so forth. I always promise myself to clean it up before I actually use it anywhere. Sometimes I even do. Does anyone else do this?

    To err is human to really elephant it up you need a computer

    C Offline
    C Offline
    CPallini
    wrote on last edited by
    #17

    Yes, of course. 'foo', 'bar', 'goo' and 'boo' are my favourites. :-D

    "In testa che avete, Signor di Ceprano?" -- Rigoletto

    1 Reply Last reply
    0
    • R rnbergren

      so frequently I find myself doing a proof of concept very short code that I am going to flush out later. Sometimes I even flush it. Pun intended. Anyway I frequently use variables like the following. astr - it is A String Temp table #ewww - because the data in the table is stinky at best. and so forth. I always promise myself to clean it up before I actually use it anywhere. Sometimes I even do. Does anyone else do this?

      To err is human to really elephant it up you need a computer

      W Offline
      W Offline
      Wizard of Sleeves
      wrote on last edited by
      #18

      It seems like I am the only one, but I am with you on this one... sort of. The only non descriptive variables I use for i, j & k in for loops. This is a throw back to my Fortran programming days. i, j & k were integers, other letters were floats. However. When I say descriptive, I do use names like 'something', 'stuff', 'thisOne', 'thatThing', etc. Sometimes, these do creep into production code, but not in a way that is confusing to the future being that has to deal with my code.

      Nothing succeeds like a budgie without teeth.

      G 1 Reply Last reply
      0
      • R rnbergren

        so frequently I find myself doing a proof of concept very short code that I am going to flush out later. Sometimes I even flush it. Pun intended. Anyway I frequently use variables like the following. astr - it is A String Temp table #ewww - because the data in the table is stinky at best. and so forth. I always promise myself to clean it up before I actually use it anywhere. Sometimes I even do. Does anyone else do this?

        To err is human to really elephant it up you need a computer

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #19

        There is nothing worse, as a support engineer, than working through some code and coming to a line that says something like:

        /* Note: Needs to be fixed before general release. */

        1 Reply Last reply
        0
        • R rnbergren

          so frequently I find myself doing a proof of concept very short code that I am going to flush out later. Sometimes I even flush it. Pun intended. Anyway I frequently use variables like the following. astr - it is A String Temp table #ewww - because the data in the table is stinky at best. and so forth. I always promise myself to clean it up before I actually use it anywhere. Sometimes I even do. Does anyone else do this?

          To err is human to really elephant it up you need a computer

          M Offline
          M Offline
          Martin Hart Turner
          wrote on last edited by
          #20

          Nope, my OCD won’t let me do such things. Quick an dirty code as well as production get the full treatment!

          1 Reply Last reply
          0
          • R rnbergren

            so frequently I find myself doing a proof of concept very short code that I am going to flush out later. Sometimes I even flush it. Pun intended. Anyway I frequently use variables like the following. astr - it is A String Temp table #ewww - because the data in the table is stinky at best. and so forth. I always promise myself to clean it up before I actually use it anywhere. Sometimes I even do. Does anyone else do this?

            To err is human to really elephant it up you need a computer

            A Offline
            A Offline
            ACRowland
            wrote on last edited by
            #21

            Well, if I'm writing a very short procedure purely as a way to check it works or compare two methods that have occurred to me, and am probably doing it in a test rig, then yes, I will use short variable names for speed. But I do it properly when I rewrite the code into the actual program. One thing I will admit to: if I write a short utility function, one or two lines... you know, to return a filename without the extension, or the _n_th word in a string or something... I will often use astr, x etc. And counters are i. Always. Unless there is a nested loop, in which case one of them is j. Unless the code is long and complicated, in which case one is outer and the other inner. Should I hang my head in shame? [Please specify precise angle]

            1 Reply Last reply
            0
            • R rnbergren

              so frequently I find myself doing a proof of concept very short code that I am going to flush out later. Sometimes I even flush it. Pun intended. Anyway I frequently use variables like the following. astr - it is A String Temp table #ewww - because the data in the table is stinky at best. and so forth. I always promise myself to clean it up before I actually use it anywhere. Sometimes I even do. Does anyone else do this?

              To err is human to really elephant it up you need a computer

              B Offline
              B Offline
              BernardIE5317
              wrote on last edited by
              #22

              When learning the language (C++) I utilize class names cfoobar cgoobar and choobar as needed. Never needed a cjoobar. Also as per FORTRAN i often utilize i j k for loop counters. Otherwise I utilize descriptive variable names even lengthy ones unless the lengthy type name is conveniently nearby to provide the context.

              1 Reply Last reply
              0
              • R rnbergren

                so frequently I find myself doing a proof of concept very short code that I am going to flush out later. Sometimes I even flush it. Pun intended. Anyway I frequently use variables like the following. astr - it is A String Temp table #ewww - because the data in the table is stinky at best. and so forth. I always promise myself to clean it up before I actually use it anywhere. Sometimes I even do. Does anyone else do this?

                To err is human to really elephant it up you need a computer

                P Offline
                P Offline
                Pete Kelley
                wrote on last edited by
                #23

                I don't object to others doing that, but to think about code I do better to "think in code".
                So the comments about "habits" really apply here. If any identifier is unconventional/silly I won't be focused on the intent of the code.
                Secondly - the code that I do as a "one-off" often turns out to be useful and adopted in another project or context. It drags down my time and effort if I need to go back and tidy up and refactor.
                Lastly - I was part of a moderately sized audience for a product demonstration once. As often happens the "presentation gods" were unkind. The demo started going awry and exposing all kinds of errors, exposing dopey-silly stuff that the developers probably NEVER intended to be part of a marketing demo.
                I felt awful for the marketing guy that had to tap dance around to try to save this humiliating, failing pitch.

                G 1 Reply Last reply
                0
                • R rnbergren

                  so frequently I find myself doing a proof of concept very short code that I am going to flush out later. Sometimes I even flush it. Pun intended. Anyway I frequently use variables like the following. astr - it is A String Temp table #ewww - because the data in the table is stinky at best. and so forth. I always promise myself to clean it up before I actually use it anywhere. Sometimes I even do. Does anyone else do this?

                  To err is human to really elephant it up you need a computer

                  G Offline
                  G Offline
                  gervacleto
                  wrote on last edited by
                  #24

                  Yes, but only in a situation like this: 1) I need to change something in a database, that is really complicated to do using only SQL instructions. 2) Using any of my programs, I create a new button. I never use the name proposed by Visual Studio, but in this case it does not matter :) 3) I create the code I need to modify the database (Read data, change it, write it back) 4) I run the program and go to the module that has my button. 4a) Of course, I press the button. 5) The job is carried on. 6) I stop the program. 7) I delete the button That's it. The button's life is just the time it takes to change my database. (Or whatever stuff must be done)

                  1 Reply Last reply
                  0
                  • R rnbergren

                    so frequently I find myself doing a proof of concept very short code that I am going to flush out later. Sometimes I even flush it. Pun intended. Anyway I frequently use variables like the following. astr - it is A String Temp table #ewww - because the data in the table is stinky at best. and so forth. I always promise myself to clean it up before I actually use it anywhere. Sometimes I even do. Does anyone else do this?

                    To err is human to really elephant it up you need a computer

                    H Offline
                    H Offline
                    honey the codewitch
                    wrote on last edited by
                    #25

                    Never in production code. Many of my solutions include a "scratch" project which I use as a testbed for writing code like you mention. The app never sees the light of day. The code never gets pasted from that app to the real apps.

                    Real programmers use butterflies

                    1 Reply Last reply
                    0
                    • R rnbergren

                      so frequently I find myself doing a proof of concept very short code that I am going to flush out later. Sometimes I even flush it. Pun intended. Anyway I frequently use variables like the following. astr - it is A String Temp table #ewww - because the data in the table is stinky at best. and so forth. I always promise myself to clean it up before I actually use it anywhere. Sometimes I even do. Does anyone else do this?

                      To err is human to really elephant it up you need a computer

                      W Offline
                      W Offline
                      W Balboos GHB
                      wrote on last edited by
                      #26

                      Well, it VARIES. (Obligatory Answer). Like many here, I use i,j,k, and occasionally other single letters for loops and counters. It's habitual enough that their purpose actually screams out "I am a counter". But, in general, I do it in camelCase because it's eye-friendly to me and follow the following: "If you don't have time to do it right the first time, how will you find the time to do it again?"

                      Ravings en masse^

                      "The difference between genius and stupidity is that genius has its limits." - Albert Einstein

                      "If you are searching for perfection in others, then you seek disappointment. If you seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010

                      1 Reply Last reply
                      0
                      • R rnbergren

                        so frequently I find myself doing a proof of concept very short code that I am going to flush out later. Sometimes I even flush it. Pun intended. Anyway I frequently use variables like the following. astr - it is A String Temp table #ewww - because the data in the table is stinky at best. and so forth. I always promise myself to clean it up before I actually use it anywhere. Sometimes I even do. Does anyone else do this?

                        To err is human to really elephant it up you need a computer

                        R Offline
                        R Offline
                        Rusty Bullet
                        wrote on last edited by
                        #27

                        IBHosed - variable for checking connections

                        1 Reply Last reply
                        0
                        • OriginalGriffO OriginalGriff

                          I'm with Marc: never. Why not? Because you will not find the time to go back and correct it - it will be permanent. That's why I "do it right" even for throwaway apps: parameterized queries, proper names, no default control names from Visual Studio, and so forth. Do it right all the time, and you don't get into bad habits which enter production cycle.

                          "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!

                          A Offline
                          A Offline
                          agolddog
                          wrote on last edited by
                          #28

                          This. And, don't use names like 'astr'. Hovering in VS will tell you it's a string. Don't waste time and space giving redundant information. I've said it for decades. It's usually not that much harder to be right than close to right. Be right.

                          1 Reply Last reply
                          0
                          • R rnbergren

                            so frequently I find myself doing a proof of concept very short code that I am going to flush out later. Sometimes I even flush it. Pun intended. Anyway I frequently use variables like the following. astr - it is A String Temp table #ewww - because the data in the table is stinky at best. and so forth. I always promise myself to clean it up before I actually use it anywhere. Sometimes I even do. Does anyone else do this?

                            To err is human to really elephant it up you need a computer

                            O Offline
                            O Offline
                            obermd
                            wrote on last edited by
                            #29

                            I tend to use descriptive names. I keep this code around for 10 years (yep, 10 years) and I've discovered I sometimes need to go back to it. Now the oddest name I used was the loop control in a language that didn't have infinite loops. The loop was (old ALL CAPS language) DO .... UNTIL HELLFREEZESOVER Unfortunately that program terminated in 2004 when the Red Sox won the World Series. :)

                            1 Reply Last reply
                            0
                            • R rnbergren

                              so frequently I find myself doing a proof of concept very short code that I am going to flush out later. Sometimes I even flush it. Pun intended. Anyway I frequently use variables like the following. astr - it is A String Temp table #ewww - because the data in the table is stinky at best. and so forth. I always promise myself to clean it up before I actually use it anywhere. Sometimes I even do. Does anyone else do this?

                              To err is human to really elephant it up you need a computer

                              M Offline
                              M Offline
                              MSBassSinger
                              wrote on last edited by
                              #30

                              Code right or code not. There is no try. :)

                              J 1 Reply Last reply
                              0
                              • M MSBassSinger

                                Code right or code not. There is no try. :)

                                J Offline
                                J Offline
                                Jeff Moden
                                wrote on last edited by
                                #31

                                From the original post... Does anyone else do this? Absolutely not. I learned a long time ago that a lot of POP code becomes production code. Like one of the other respondents posted... Code right or code not. There is no try.

                                1 Reply Last reply
                                0
                                • W Wizard of Sleeves

                                  It seems like I am the only one, but I am with you on this one... sort of. The only non descriptive variables I use for i, j & k in for loops. This is a throw back to my Fortran programming days. i, j & k were integers, other letters were floats. However. When I say descriptive, I do use names like 'something', 'stuff', 'thisOne', 'thatThing', etc. Sometimes, these do creep into production code, but not in a way that is confusing to the future being that has to deal with my code.

                                  Nothing succeeds like a budgie without teeth.

                                  G Offline
                                  G Offline
                                  Gary R Wheeler
                                  wrote on last edited by
                                  #32

                                  Wizard of Sleeves wrote:

                                  I use for i, j & k in for loops

                                  I have the same less-than-great habit, also a hangover from my FORTRAN days (the fact that I type FORTRAN in upper case tells you how long ago that was). I have moderated the habit a little over the years, often making the names of the form _ABC_i where the _ABC_ prefix is a descriptive acronym for the array being indexed.

                                  Software Zen: delete this;

                                  1 Reply Last reply
                                  0
                                  • P Pete Kelley

                                    I don't object to others doing that, but to think about code I do better to "think in code".
                                    So the comments about "habits" really apply here. If any identifier is unconventional/silly I won't be focused on the intent of the code.
                                    Secondly - the code that I do as a "one-off" often turns out to be useful and adopted in another project or context. It drags down my time and effort if I need to go back and tidy up and refactor.
                                    Lastly - I was part of a moderately sized audience for a product demonstration once. As often happens the "presentation gods" were unkind. The demo started going awry and exposing all kinds of errors, exposing dopey-silly stuff that the developers probably NEVER intended to be part of a marketing demo.
                                    I felt awful for the marketing guy that had to tap dance around to try to save this humiliating, failing pitch.

                                    G Offline
                                    G Offline
                                    Gary R Wheeler
                                    wrote on last edited by
                                    #33

                                    Pete Kelley wrote:

                                    I felt awful for the marketing guy that had to tap dance around to try to save this humiliating, failing pitch

                                    Wow. It must have really been awful. In my case if I saw a marketing guy drowning in gasoline, I'd hand him a lit match...

                                    Software Zen: delete this;

                                    1 Reply Last reply
                                    0
                                    • R rnbergren

                                      so frequently I find myself doing a proof of concept very short code that I am going to flush out later. Sometimes I even flush it. Pun intended. Anyway I frequently use variables like the following. astr - it is A String Temp table #ewww - because the data in the table is stinky at best. and so forth. I always promise myself to clean it up before I actually use it anywhere. Sometimes I even do. Does anyone else do this?

                                      To err is human to really elephant it up you need a computer

                                      D Offline
                                      D Offline
                                      Daniel Will
                                      wrote on last edited by
                                      #34

                                      Err... I would never hire you if I was an interviewer. I name everything properly, even in a throw away / practice program. Habit is something that's hard to change. Have a good habit.

                                      1 Reply Last reply
                                      0
                                      • R rnbergren

                                        so frequently I find myself doing a proof of concept very short code that I am going to flush out later. Sometimes I even flush it. Pun intended. Anyway I frequently use variables like the following. astr - it is A String Temp table #ewww - because the data in the table is stinky at best. and so forth. I always promise myself to clean it up before I actually use it anywhere. Sometimes I even do. Does anyone else do this?

                                        To err is human to really elephant it up you need a computer

                                        U Offline
                                        U Offline
                                        User 14060113
                                        wrote on last edited by
                                        #35

                                        I think you should always make the decision before you code: Is it one-way disposable code or is it production-level clean code. The latter can take up to twice as much time, so you should decide carefully. So when you decide to use throw-away code in production, you *have* to invest some more time to make it nice and neat. At least that's the way I do it.

                                        1 Reply Last reply
                                        0
                                        • R rnbergren

                                          so frequently I find myself doing a proof of concept very short code that I am going to flush out later. Sometimes I even flush it. Pun intended. Anyway I frequently use variables like the following. astr - it is A String Temp table #ewww - because the data in the table is stinky at best. and so forth. I always promise myself to clean it up before I actually use it anywhere. Sometimes I even do. Does anyone else do this?

                                          To err is human to really elephant it up you need a computer

                                          S Offline
                                          S Offline
                                          StarNamer work
                                          wrote on last edited by
                                          #36

                                          Good naming conventions are essential | CommitStrip[^]

                                          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