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. Names

Names

Scheduled Pinned Locked Moved The Lounge
questionhelp
43 Posts 17 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.
  • G Offline
    G Offline
    grralph1
    wrote on last edited by
    #1

    rnbergren's recent post about variable names was good. Lots of helpful advice poured in. I didn't respond but I think that I should have done so. rnbergren's post was about using frivolous or silly names for Variables and other things in proof of concept code and then using this as in copy and pasting in the real code. Sometimes changing it and sometimes not. Enjoying it or not. Most responses were like, do it properly in the first place and it won't end up in your production code. I agree. I have done it in the past but not anymore. However I do like to be creative and sometimes I look at a previously named function, sub or Var name and marvel in it's relevance. I often comment/remark on the name as well so that it makes sense to others. Sander Wrote:

    Quote:

    So no, I've made doing it "right" a habit and would not even think about naming something "astr" or "ewww" Smile | :)

    OK ewww is a bit weird unless the table has field names like ewww and ahhh. (I love and respect Sander.) I used to always use nresponse as the throw away variable name for things like the result of an input box within a sub. I remember using ansStr once which was commented as 'answer string'. So close to astr. Personally I don't see the problem especially with a throwaway Variable. It is only there for a few micro seconds. Every other name is important. So I am interested in what others use for a throw away variable names used to hold a response from something like an inputbox or similar. Do you always use the same name and if so what is it? Or do you change it to suit the situation?

    "Rock journalism is people who can't write interviewing people who can't talk for people who can't read." Frank Zappa 1980

    R OriginalGriffO J L H 14 Replies Last reply
    0
    • G grralph1

      rnbergren's recent post about variable names was good. Lots of helpful advice poured in. I didn't respond but I think that I should have done so. rnbergren's post was about using frivolous or silly names for Variables and other things in proof of concept code and then using this as in copy and pasting in the real code. Sometimes changing it and sometimes not. Enjoying it or not. Most responses were like, do it properly in the first place and it won't end up in your production code. I agree. I have done it in the past but not anymore. However I do like to be creative and sometimes I look at a previously named function, sub or Var name and marvel in it's relevance. I often comment/remark on the name as well so that it makes sense to others. Sander Wrote:

      Quote:

      So no, I've made doing it "right" a habit and would not even think about naming something "astr" or "ewww" Smile | :)

      OK ewww is a bit weird unless the table has field names like ewww and ahhh. (I love and respect Sander.) I used to always use nresponse as the throw away variable name for things like the result of an input box within a sub. I remember using ansStr once which was commented as 'answer string'. So close to astr. Personally I don't see the problem especially with a throwaway Variable. It is only there for a few micro seconds. Every other name is important. So I am interested in what others use for a throw away variable names used to hold a response from something like an inputbox or similar. Do you always use the same name and if so what is it? Or do you change it to suit the situation?

      "Rock journalism is people who can't write interviewing people who can't talk for people who can't read." Frank Zappa 1980

      R Offline
      R Offline
      rnbergren
      wrote on last edited by
      #2

      I already voted. :) Once I am past like 2 stupid variable names or I am past 15 lines of code. Well the whole thing needs to be cleaned up for the masses. I pretty much only use astr for strings and some other silly ones. Fun discussion. can't wait to see the posts.

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

      G 1 Reply Last reply
      0
      • G grralph1

        rnbergren's recent post about variable names was good. Lots of helpful advice poured in. I didn't respond but I think that I should have done so. rnbergren's post was about using frivolous or silly names for Variables and other things in proof of concept code and then using this as in copy and pasting in the real code. Sometimes changing it and sometimes not. Enjoying it or not. Most responses were like, do it properly in the first place and it won't end up in your production code. I agree. I have done it in the past but not anymore. However I do like to be creative and sometimes I look at a previously named function, sub or Var name and marvel in it's relevance. I often comment/remark on the name as well so that it makes sense to others. Sander Wrote:

        Quote:

        So no, I've made doing it "right" a habit and would not even think about naming something "astr" or "ewww" Smile | :)

        OK ewww is a bit weird unless the table has field names like ewww and ahhh. (I love and respect Sander.) I used to always use nresponse as the throw away variable name for things like the result of an input box within a sub. I remember using ansStr once which was commented as 'answer string'. So close to astr. Personally I don't see the problem especially with a throwaway Variable. It is only there for a few micro seconds. Every other name is important. So I am interested in what others use for a throw away variable names used to hold a response from something like an inputbox or similar. Do you always use the same name and if so what is it? Or do you change it to suit the situation?

        "Rock journalism is people who can't write interviewing people who can't talk for people who can't read." Frank Zappa 1980

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

        C# has "institutionalized" throw-away variable names: Discards - C# Guide | Microsoft Docs[^] but they aren't quite what you are talking about. If you mean that an input box returns a value and you'll use it just once, then don't store it in a variable: use it inline, or give it a sensible name if that'll make your "single line of code" unreadable. "result" is a good one - it at least tells you that it's probably short term, but give you a clue what it contains if extra code is added at a later point.

        DialogResult result = MessageBox.Show(prompt, caption, MessageBoxButtons.YesNoCancel);
        if (result == DialogResult.Cancel) return;
        if (result == DialogResult.Yes)
        {
        ...

        If later code makes the "Cancel" branch bigger (logging, "Are you sure?" that kinda thing maybe) then the sense of the code is retained.

        "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

        J G 2 Replies Last reply
        0
        • G grralph1

          rnbergren's recent post about variable names was good. Lots of helpful advice poured in. I didn't respond but I think that I should have done so. rnbergren's post was about using frivolous or silly names for Variables and other things in proof of concept code and then using this as in copy and pasting in the real code. Sometimes changing it and sometimes not. Enjoying it or not. Most responses were like, do it properly in the first place and it won't end up in your production code. I agree. I have done it in the past but not anymore. However I do like to be creative and sometimes I look at a previously named function, sub or Var name and marvel in it's relevance. I often comment/remark on the name as well so that it makes sense to others. Sander Wrote:

          Quote:

          So no, I've made doing it "right" a habit and would not even think about naming something "astr" or "ewww" Smile | :)

          OK ewww is a bit weird unless the table has field names like ewww and ahhh. (I love and respect Sander.) I used to always use nresponse as the throw away variable name for things like the result of an input box within a sub. I remember using ansStr once which was commented as 'answer string'. So close to astr. Personally I don't see the problem especially with a throwaway Variable. It is only there for a few micro seconds. Every other name is important. So I am interested in what others use for a throw away variable names used to hold a response from something like an inputbox or similar. Do you always use the same name and if so what is it? Or do you change it to suit the situation?

          "Rock journalism is people who can't write interviewing people who can't talk for people who can't read." Frank Zappa 1980

          J Offline
          J Offline
          Jorgen Andersson
          wrote on last edited by
          #4

          Guilty. I tend to reuse "CommandString". Only change it if I use more than one at the same time.

          Wrong is evil and must be defeated. - Jeff Ello

          G 1 Reply Last reply
          0
          • OriginalGriffO OriginalGriff

            C# has "institutionalized" throw-away variable names: Discards - C# Guide | Microsoft Docs[^] but they aren't quite what you are talking about. If you mean that an input box returns a value and you'll use it just once, then don't store it in a variable: use it inline, or give it a sensible name if that'll make your "single line of code" unreadable. "result" is a good one - it at least tells you that it's probably short term, but give you a clue what it contains if extra code is added at a later point.

            DialogResult result = MessageBox.Show(prompt, caption, MessageBoxButtons.YesNoCancel);
            if (result == DialogResult.Cancel) return;
            if (result == DialogResult.Yes)
            {
            ...

            If later code makes the "Cancel" branch bigger (logging, "Are you sure?" that kinda thing maybe) then the sense of the code is retained.

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

            J Offline
            J Offline
            Jorgen Andersson
            wrote on last edited by
            #5

            OriginalGriff wrote:

            then don't store it in a variable: use it inline

            Except when it kills readability, like Commandstrings. <edit>Didn't even read the full sentence properly. :doh:

            Wrong is evil and must be defeated. - Jeff Ello

            OriginalGriffO 1 Reply Last reply
            0
            • J Jorgen Andersson

              OriginalGriff wrote:

              then don't store it in a variable: use it inline

              Except when it kills readability, like Commandstrings. <edit>Didn't even read the full sentence properly. :doh:

              Wrong is evil and must be defeated. - Jeff Ello

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

              Jörgen Andersson wrote:

              <edit>Didn't even read the full sentence properly

              :D

              "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

              J 1 Reply Last reply
              0
              • OriginalGriffO OriginalGriff

                Jörgen Andersson wrote:

                <edit>Didn't even read the full sentence properly

                :D

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

                J Offline
                J Offline
                Jorgen Andersson
                wrote on last edited by
                #7

                I'll blame an unfortunate linefeed.

                Wrong is evil and must be defeated. - Jeff Ello

                1 Reply Last reply
                0
                • R rnbergren

                  I already voted. :) Once I am past like 2 stupid variable names or I am past 15 lines of code. Well the whole thing needs to be cleaned up for the masses. I pretty much only use astr for strings and some other silly ones. Fun discussion. can't wait to see the posts.

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

                  G Offline
                  G Offline
                  grralph1
                  wrote on last edited by
                  #8

                  Quote:

                  Fun discussion. can't wait to see the posts.

                  Yeah same here. It is something that isn't normally spoken about. Thanks for steering this one as well.

                  "Rock journalism is people who can't write interviewing people who can't talk for people who can't read." Frank Zappa 1980

                  1 Reply Last reply
                  0
                  • OriginalGriffO OriginalGriff

                    C# has "institutionalized" throw-away variable names: Discards - C# Guide | Microsoft Docs[^] but they aren't quite what you are talking about. If you mean that an input box returns a value and you'll use it just once, then don't store it in a variable: use it inline, or give it a sensible name if that'll make your "single line of code" unreadable. "result" is a good one - it at least tells you that it's probably short term, but give you a clue what it contains if extra code is added at a later point.

                    DialogResult result = MessageBox.Show(prompt, caption, MessageBoxButtons.YesNoCancel);
                    if (result == DialogResult.Cancel) return;
                    if (result == DialogResult.Yes)
                    {
                    ...

                    If later code makes the "Cancel" branch bigger (logging, "Are you sure?" that kinda thing maybe) then the sense of the code is retained.

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

                    G Offline
                    G Offline
                    grralph1
                    wrote on last edited by
                    #9

                    Yes Sensible. I like it. Thanks.

                    "Rock journalism is people who can't write interviewing people who can't talk for people who can't read." Frank Zappa 1980

                    1 Reply Last reply
                    0
                    • J Jorgen Andersson

                      Guilty. I tend to reuse "CommandString". Only change it if I use more than one at the same time.

                      Wrong is evil and must be defeated. - Jeff Ello

                      G Offline
                      G Offline
                      grralph1
                      wrote on last edited by
                      #10

                      Some say that consistency is a virtue. I think that your tendency is OK and readable. Somethings just become habits. Thanks, it is interesting.

                      "Rock journalism is people who can't write interviewing people who can't talk for people who can't read." Frank Zappa 1980

                      1 Reply Last reply
                      0
                      • G grralph1

                        rnbergren's recent post about variable names was good. Lots of helpful advice poured in. I didn't respond but I think that I should have done so. rnbergren's post was about using frivolous or silly names for Variables and other things in proof of concept code and then using this as in copy and pasting in the real code. Sometimes changing it and sometimes not. Enjoying it or not. Most responses were like, do it properly in the first place and it won't end up in your production code. I agree. I have done it in the past but not anymore. However I do like to be creative and sometimes I look at a previously named function, sub or Var name and marvel in it's relevance. I often comment/remark on the name as well so that it makes sense to others. Sander Wrote:

                        Quote:

                        So no, I've made doing it "right" a habit and would not even think about naming something "astr" or "ewww" Smile | :)

                        OK ewww is a bit weird unless the table has field names like ewww and ahhh. (I love and respect Sander.) I used to always use nresponse as the throw away variable name for things like the result of an input box within a sub. I remember using ansStr once which was commented as 'answer string'. So close to astr. Personally I don't see the problem especially with a throwaway Variable. It is only there for a few micro seconds. Every other name is important. So I am interested in what others use for a throw away variable names used to hold a response from something like an inputbox or similar. Do you always use the same name and if so what is it? Or do you change it to suit the situation?

                        "Rock journalism is people who can't write interviewing people who can't talk for people who can't read." Frank Zappa 1980

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

                        I've never used silly variable names, even for throw away variables, but I do use result and response quite often. I try to use generic variable names in specific types of methods, such as methods used in the data access layer, so I can make templates from them. I try to balance readability, simplicity, and functionality when writing code. That's why I found it quite difficult transitioning from the old way of writing variable names (a$ as an example) to writing out full length variable names such as errorLogEntity.

                        "When you are dead, you won't even know that you are dead. It's a pain only felt by others; same thing when you are stupid." Ignorant - An individual without knowledge, but is willing to learn. Stupid - An individual without knowledge and is incapable of learning. Idiot - An individual without knowledge and allows social media to do the thinking for them.

                        G 1 Reply Last reply
                        0
                        • L Lost User

                          I've never used silly variable names, even for throw away variables, but I do use result and response quite often. I try to use generic variable names in specific types of methods, such as methods used in the data access layer, so I can make templates from them. I try to balance readability, simplicity, and functionality when writing code. That's why I found it quite difficult transitioning from the old way of writing variable names (a$ as an example) to writing out full length variable names such as errorLogEntity.

                          "When you are dead, you won't even know that you are dead. It's a pain only felt by others; same thing when you are stupid." Ignorant - An individual without knowledge, but is willing to learn. Stupid - An individual without knowledge and is incapable of learning. Idiot - An individual without knowledge and allows social media to do the thinking for them.

                          G Offline
                          G Offline
                          grralph1
                          wrote on last edited by
                          #12

                          Sensible. I like what you are saying. It just makes sense. Repetition for short throw away vars and full length names for important and longer living ones. Some may think that a$ was a bit silly, but hey, it was common way back.

                          "Rock journalism is people who can't write interviewing people who can't talk for people who can't read." Frank Zappa 1980

                          1 Reply Last reply
                          0
                          • G grralph1

                            rnbergren's recent post about variable names was good. Lots of helpful advice poured in. I didn't respond but I think that I should have done so. rnbergren's post was about using frivolous or silly names for Variables and other things in proof of concept code and then using this as in copy and pasting in the real code. Sometimes changing it and sometimes not. Enjoying it or not. Most responses were like, do it properly in the first place and it won't end up in your production code. I agree. I have done it in the past but not anymore. However I do like to be creative and sometimes I look at a previously named function, sub or Var name and marvel in it's relevance. I often comment/remark on the name as well so that it makes sense to others. Sander Wrote:

                            Quote:

                            So no, I've made doing it "right" a habit and would not even think about naming something "astr" or "ewww" Smile | :)

                            OK ewww is a bit weird unless the table has field names like ewww and ahhh. (I love and respect Sander.) I used to always use nresponse as the throw away variable name for things like the result of an input box within a sub. I remember using ansStr once which was commented as 'answer string'. So close to astr. Personally I don't see the problem especially with a throwaway Variable. It is only there for a few micro seconds. Every other name is important. So I am interested in what others use for a throw away variable names used to hold a response from something like an inputbox or similar. Do you always use the same name and if so what is it? Or do you change it to suit the situation?

                            "Rock journalism is people who can't write interviewing people who can't talk for people who can't read." Frank Zappa 1980

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

                            for loop counters i use i,j,k, etc for results from routines i use "result" for throwaways I usually use an abbreviated name that indicates the purpose. if the purpose is obvious, and the variable has small locality in my routine, i may even name it something like "fn" to hold a filename, or p to hold a point.

                            Real programmers use butterflies

                            G M 2 Replies Last reply
                            0
                            • G grralph1

                              rnbergren's recent post about variable names was good. Lots of helpful advice poured in. I didn't respond but I think that I should have done so. rnbergren's post was about using frivolous or silly names for Variables and other things in proof of concept code and then using this as in copy and pasting in the real code. Sometimes changing it and sometimes not. Enjoying it or not. Most responses were like, do it properly in the first place and it won't end up in your production code. I agree. I have done it in the past but not anymore. However I do like to be creative and sometimes I look at a previously named function, sub or Var name and marvel in it's relevance. I often comment/remark on the name as well so that it makes sense to others. Sander Wrote:

                              Quote:

                              So no, I've made doing it "right" a habit and would not even think about naming something "astr" or "ewww" Smile | :)

                              OK ewww is a bit weird unless the table has field names like ewww and ahhh. (I love and respect Sander.) I used to always use nresponse as the throw away variable name for things like the result of an input box within a sub. I remember using ansStr once which was commented as 'answer string'. So close to astr. Personally I don't see the problem especially with a throwaway Variable. It is only there for a few micro seconds. Every other name is important. So I am interested in what others use for a throw away variable names used to hold a response from something like an inputbox or similar. Do you always use the same name and if so what is it? Or do you change it to suit the situation?

                              "Rock journalism is people who can't write interviewing people who can't talk for people who can't read." Frank Zappa 1980

                              Sander RosselS Offline
                              Sander RosselS Offline
                              Sander Rossel
                              wrote on last edited by
                              #14

                              grralph1 wrote:

                              I love and respect Sander.

                              Love you too man #nohomo #bromance 😘

                              Best, Sander Azure DevOps Succinctly (free eBook) Azure Serverless Succinctly (free eBook) Migrating Apps to the Cloud with Azure arrgh.js - Bringing LINQ to JavaScript

                              G 1 Reply Last reply
                              0
                              • Sander RosselS Sander Rossel

                                grralph1 wrote:

                                I love and respect Sander.

                                Love you too man #nohomo #bromance 😘

                                Best, Sander Azure DevOps Succinctly (free eBook) Azure Serverless Succinctly (free eBook) Migrating Apps to the Cloud with Azure arrgh.js - Bringing LINQ to JavaScript

                                G Offline
                                G Offline
                                grralph1
                                wrote on last edited by
                                #15

                                Haha :thumbsup:

                                "Rock journalism is people who can't write interviewing people who can't talk for people who can't read." Frank Zappa 1980

                                1 Reply Last reply
                                0
                                • H honey the codewitch

                                  for loop counters i use i,j,k, etc for results from routines i use "result" for throwaways I usually use an abbreviated name that indicates the purpose. if the purpose is obvious, and the variable has small locality in my routine, i may even name it something like "fn" to hold a filename, or p to hold a point.

                                  Real programmers use butterflies

                                  G Offline
                                  G Offline
                                  grralph1
                                  wrote on last edited by
                                  #16

                                  I am, pretty much the same. Thanks.

                                  "Rock journalism is people who can't write interviewing people who can't talk for people who can't read." Frank Zappa 1980

                                  1 Reply Last reply
                                  0
                                  • G grralph1

                                    rnbergren's recent post about variable names was good. Lots of helpful advice poured in. I didn't respond but I think that I should have done so. rnbergren's post was about using frivolous or silly names for Variables and other things in proof of concept code and then using this as in copy and pasting in the real code. Sometimes changing it and sometimes not. Enjoying it or not. Most responses were like, do it properly in the first place and it won't end up in your production code. I agree. I have done it in the past but not anymore. However I do like to be creative and sometimes I look at a previously named function, sub or Var name and marvel in it's relevance. I often comment/remark on the name as well so that it makes sense to others. Sander Wrote:

                                    Quote:

                                    So no, I've made doing it "right" a habit and would not even think about naming something "astr" or "ewww" Smile | :)

                                    OK ewww is a bit weird unless the table has field names like ewww and ahhh. (I love and respect Sander.) I used to always use nresponse as the throw away variable name for things like the result of an input box within a sub. I remember using ansStr once which was commented as 'answer string'. So close to astr. Personally I don't see the problem especially with a throwaway Variable. It is only there for a few micro seconds. Every other name is important. So I am interested in what others use for a throw away variable names used to hold a response from something like an inputbox or similar. Do you always use the same name and if so what is it? Or do you change it to suit the situation?

                                    "Rock journalism is people who can't write interviewing people who can't talk for people who can't read." Frank Zappa 1980

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

                                    I did respond to the previously mentioned post, as one who does use silly names. Perhaps a new topic, but I also leave silly (funny?) comments in the code for whomever receives the punishment of having to fix modify my code later.

                                    // Note: No pterodactyls were harmed in the testing of this code, but the same cannot be guaranteed once released in the wild.

                                    if (...) {
                                    -
                                    -
                                    } else {
                                    // Sit back, relax, and have a beer.
                                    }

                                    Nothing succeeds like a budgie without teeth.

                                    G 1 Reply Last reply
                                    0
                                    • H honey the codewitch

                                      for loop counters i use i,j,k, etc for results from routines i use "result" for throwaways I usually use an abbreviated name that indicates the purpose. if the purpose is obvious, and the variable has small locality in my routine, i may even name it something like "fn" to hold a filename, or p to hold a point.

                                      Real programmers use butterflies

                                      M Offline
                                      M Offline
                                      Mike Winiberg
                                      wrote on last edited by
                                      #18

                                      This discussion is quite fascinating. Back in my youth (when dinosaurs roamed the earth), languages restricted both length of variable names and enforced type based on initial (or even only!) letters. So, I to N would be integer, everything else floating point. This is, I believe the origin of the common use of i,j,k for integer loop variables etc, and x,y,z (also algebraic) for common floats. Someone I once employed would have complex calculations etc using variables like x, xx, xxx, xxxx and y,yy,yyy,yyyy etc - write only code if ever there was any. The advent of unrestricted variable names led to the opposite extreme, where variable (and function) names became so long and complex eg: doubleCalculateOffsetForWaveFunction(intScaleFactorForWaveFunction,floatWaveFunctionSeedValue) doubleCalculateOffsetForInverseWaveFunction(intScaleFactorForWaveFunction,floatWaveFunctionSeedValue) with variations on camelCase, "_" separators etc) that code became tedious to type correctly and especially to refactor before the rise of the modern IDE; impossible to read and understand because of the effort needed to parse the variable names, especially when lots were very similar in structure etc etc. (How would you know from reading the two declarations above whether the parameters were the correct variables eg: you might indeed want to use the same seeds here, or it might need different ones, so why not just use 'seed' etc) BUT, you have to beware of making anything other than throwaway variable names too specific to the algorithm rather than their usage - because this can make them ambiguous or misleading in meaning: does 'intUserValue' indicate something entered by the user, some property of the user, the user's value to the organisation etc Making up variable names can be one of the hardest parts of coding something especially if one coding house uses identical names differently to another. I recently dug myself into a hole migrating a business app from SAGE accounts to XERO, because in SAGE anything (Nominal ledger entries, customers, suppliers etc) can be in an 'account'. In XERO only nominal items go in 'accounts', customers go in 'contacts'. I only discovered this when I tried to post a customer invoice and found that I couldn't assign it to an 'account', only to a 'contact'. Then there are the times when you use a library function return value in-line, there's a bug, and even your modern sophisticated IDE has no way to inspect the return value without dropping right down to assembler level

                                      G H S 3 Replies Last reply
                                      0
                                      • G grralph1

                                        rnbergren's recent post about variable names was good. Lots of helpful advice poured in. I didn't respond but I think that I should have done so. rnbergren's post was about using frivolous or silly names for Variables and other things in proof of concept code and then using this as in copy and pasting in the real code. Sometimes changing it and sometimes not. Enjoying it or not. Most responses were like, do it properly in the first place and it won't end up in your production code. I agree. I have done it in the past but not anymore. However I do like to be creative and sometimes I look at a previously named function, sub or Var name and marvel in it's relevance. I often comment/remark on the name as well so that it makes sense to others. Sander Wrote:

                                        Quote:

                                        So no, I've made doing it "right" a habit and would not even think about naming something "astr" or "ewww" Smile | :)

                                        OK ewww is a bit weird unless the table has field names like ewww and ahhh. (I love and respect Sander.) I used to always use nresponse as the throw away variable name for things like the result of an input box within a sub. I remember using ansStr once which was commented as 'answer string'. So close to astr. Personally I don't see the problem especially with a throwaway Variable. It is only there for a few micro seconds. Every other name is important. So I am interested in what others use for a throw away variable names used to hold a response from something like an inputbox or similar. Do you always use the same name and if so what is it? Or do you change it to suit the situation?

                                        "Rock journalism is people who can't write interviewing people who can't talk for people who can't read." Frank Zappa 1980

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

                                        I use "result" or "response" when it is really a throw away variable for debugging purposes. Using "ewww" or "blurpp" is crossing the line. We are working, not joking with friends. Even if it's a personal project, bad habits get carried to other things.

                                        G 1 Reply Last reply
                                        0
                                        • M Mike Winiberg

                                          This discussion is quite fascinating. Back in my youth (when dinosaurs roamed the earth), languages restricted both length of variable names and enforced type based on initial (or even only!) letters. So, I to N would be integer, everything else floating point. This is, I believe the origin of the common use of i,j,k for integer loop variables etc, and x,y,z (also algebraic) for common floats. Someone I once employed would have complex calculations etc using variables like x, xx, xxx, xxxx and y,yy,yyy,yyyy etc - write only code if ever there was any. The advent of unrestricted variable names led to the opposite extreme, where variable (and function) names became so long and complex eg: doubleCalculateOffsetForWaveFunction(intScaleFactorForWaveFunction,floatWaveFunctionSeedValue) doubleCalculateOffsetForInverseWaveFunction(intScaleFactorForWaveFunction,floatWaveFunctionSeedValue) with variations on camelCase, "_" separators etc) that code became tedious to type correctly and especially to refactor before the rise of the modern IDE; impossible to read and understand because of the effort needed to parse the variable names, especially when lots were very similar in structure etc etc. (How would you know from reading the two declarations above whether the parameters were the correct variables eg: you might indeed want to use the same seeds here, or it might need different ones, so why not just use 'seed' etc) BUT, you have to beware of making anything other than throwaway variable names too specific to the algorithm rather than their usage - because this can make them ambiguous or misleading in meaning: does 'intUserValue' indicate something entered by the user, some property of the user, the user's value to the organisation etc Making up variable names can be one of the hardest parts of coding something especially if one coding house uses identical names differently to another. I recently dug myself into a hole migrating a business app from SAGE accounts to XERO, because in SAGE anything (Nominal ledger entries, customers, suppliers etc) can be in an 'account'. In XERO only nominal items go in 'accounts', customers go in 'contacts'. I only discovered this when I tried to post a customer invoice and found that I couldn't assign it to an 'account', only to a 'contact'. Then there are the times when you use a library function return value in-line, there's a bug, and even your modern sophisticated IDE has no way to inspect the return value without dropping right down to assembler level

                                          G Offline
                                          G Offline
                                          grralph1
                                          wrote on last edited by
                                          #20

                                          A wonderful response. Really enjoyed this one especially. Thanks. I was aware of most of the history that you mentioned. The long variable and function name thing made me nearly spit my stout out over the keyboard. I have never seen this before but I have seen similar. I usually comment on names, especially function names and occasionally with Variables if they may seem obscure. A comment is sometimes priceless.

                                          "Rock journalism is people who can't write interviewing people who can't talk for people who can't read." Frank Zappa 1980

                                          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