Free 186 More Best Homemade Tools eBook:  
Get 2,000+ tool plans, full site access, and more.

User Tag List

Results 1 to 9 of 9

Thread: Temporary Naming Convention for Software

  1. #1
    Supporting Member rgsparber's Avatar
    Join Date
    Nov 2012
    Location
    Phoenix, AZ
    Posts
    1,278
    Thanks
    733
    Thanked 2,763 Times in 650 Posts

    rgsparber's Tools

    Temporary Naming Convention for Software

    Have you ever been focused on writing software and had to come up with a temporary variable name? At times like that, my creativity is focused on the code and not on picking that variable name. I used to pick names like “junk”, “junk1”, etc and they would later come back to haunt me when I used the same name twice in a piece of code. Then a very smart programmer showed me that, built right into my keyboard, was a nice selection of unique names!

    If you are interested, please see

    http://rick.sparber.org/SNC.pdf


    Your comments are welcome. All of us are smarter than any one of us.


    Thanks,

    Rick

    Rgsparber.ya@gmail.com
    Rick.Sparber.org
    You Tube Channel: https://www.youtube.com/user/rgsparber1
    KG7MQL

    186 More Best Homemade Tools eBook
    Rick

  2. The Following User Says Thank You to rgsparber For This Useful Post:

    Toolmaker51 (Apr 27, 2017)

  3. #2
    Supporting Member tonyfoale's Avatar
    Join Date
    Nov 2016
    Location
    Spain
    Posts
    1,549
    Thanks
    679
    Thanked 2,627 Times in 705 Posts

    tonyfoale's Tools
    Quote Originally Posted by rgsparber View Post
    Have you ever been focused on writing software and had to come up with a temporary variable name? .....................

    Your comments are welcome.
    Rick,

    I don't want to appear negative, just honest, but I really, really don't like it. I like understandable and meaningful words for variables, temporary or not. That way I can come back to it 5 years later and it still makes sense.

    2000 Tool Plans

  4. #3
    Supporting Member rgsparber's Avatar
    Join Date
    Nov 2012
    Location
    Phoenix, AZ
    Posts
    1,278
    Thanks
    733
    Thanked 2,763 Times in 650 Posts

    rgsparber's Tools
    Tony,

    Here is an example of where the meaning isn't important:

    Say I want to swap A and B:

    qaz = A
    A = B
    B = qaz

    These "keyboard" names would never be used outside of the immediate vicinity.

    For names that are passed around, I like to use the initial caps format. For example, LongTermAverageFlowRate. It takes more typing, but like you said, in 5 years, it will still make sense. At my age, I will be confused tomorrow so need this long form.

    Rick
    Rick

  5. #4
    Supporting Member Frank S's Avatar
    Join Date
    Aug 2015
    Location
    Peacock TX
    Posts
    11,178
    Thanks
    1,974
    Thanked 8,766 Times in 4,195 Posts

    Frank S's Tools
    Makes me glad I'm not smart enough to write code
    Never try to tell me it can't be done
    When I have to paint I use KBS products

  6. #5
    Supporting Member rgsparber's Avatar
    Join Date
    Nov 2012
    Location
    Phoenix, AZ
    Posts
    1,278
    Thanks
    733
    Thanked 2,763 Times in 650 Posts

    rgsparber's Tools
    If you are on the HomeMadeTools site, you are plenty smart enough to write code. Code is just a logical sequence of steps that accomplish a task.

    Rick
    Rick

  7. #6
    Supporting Member tonyfoale's Avatar
    Join Date
    Nov 2016
    Location
    Spain
    Posts
    1,549
    Thanks
    679
    Thanked 2,627 Times in 705 Posts

    tonyfoale's Tools
    Quote Originally Posted by rgsparber View Post
    Tony,

    Here is an example of where the meaning isn't important:

    Say I want to swap A and B:

    qaz = A
    A = B
    B = qaz

    These "keyboard" names would never be used outside of the immediate vicinity.

    For names that are passed around, I like to use the initial caps format. For example, LongTermAverageFlowRate. It takes more typing, but like you said, in 5 years, it will still make sense. At my age, I will be confused tomorrow so need this long form.

    Rick
    Rick,

    I started coding with Fortran back when you wrote programmes on fixed format paper forms. So there was limited space for a line of code and it was usual to use the shortest variable names possible. As it was engineering/scientific work names like x,y,z and i,j,k and a,b,c fitted the job quite well. With that background added to a healthy helping of laziness I carried the short variable naming through for decades. I have still a tendency to do that but I have realised that it is much quicker overall to use unambiguous descriptive names as you show. The extra time taken for the increased typing is way less than the time taken to understand a non-descriptive bit of code the day after you wrote it.
    It was late when I replied to your post and to some extent i misunderstood your meaning of temporary. During development I often add "temporary" variables to monitor values. These are temporary in the sense that they are removed once the code is finished, I try to use meaningful names for these.
    That use of "temporary" is, of course, different from that in your "swap A & B" example, where the temp. var. qaz is actually a permanent part of your code. Anyway I still don't like it and I'd use something like "temp" or "C" in similar situations, but hey "different strokes for different folks" is what makes life interesting.

    BTW. the phrase "once the code is finished" is of course jocular.

  8. #7
    Content Editor
    Supporting Member
    DIYer's Avatar
    Join Date
    Aug 2013
    Posts
    3,056
    Thanks
    772
    Thanked 1,850 Times in 1,652 Posts
    Thanks Rick! We've added your Temporary Naming Convention to our Miscellaneous category, as well as to your builder page: Rick's Homemade Tools. Your receipt:


  9. #8
    Supporting Member C-Bag's Avatar
    Join Date
    Aug 2015
    Location
    California, central coast
    Posts
    720
    Thanks
    689
    Thanked 876 Times in 471 Posts

    C-Bag's Tools
    Quote Originally Posted by Frank S View Post
    Makes me glad I'm not smart enough to write code
    LOL! Luckily I just swallowed my coffee because it would have gotten all over the iPad!

  10. #9
    Supporting Member Toolmaker51's Avatar
    Join Date
    Feb 2016
    Location
    Midwest USA
    Posts
    5,330
    Thanks
    7,041
    Thanked 2,977 Times in 1,892 Posts

    Toolmaker51's Tools
    Quote Posted by Frank S "Makes me glad I'm not smart enough to write code"
    Quote Posted by C-Bag "LOL! Luckily I just swallowed my coffee because it would have gotten all over the iPad"
    Comment offered by Toolmaker51. Coffee isn't one of my beverages; couldn't fill watch crystal with that consumed so far. Glad and lucky enough to not have purchased equipment dependant on additional code or decoding. Bletchley Park this is not!



    186 More Best Homemade Tools eBook
    Sincerely,
    Toolmaker51
    ...we'll learn more by wandering than searching...

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •