Announcement

Collapse
No announcement yet.

Use of underscore in tag naming

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts


  • Use of underscore in tag naming

    I'm new to the Productivity series, and have noticed a general practice among other users of using underscores in their tag names when I look at example programs. Why? Since I'm new, I'm having a hard time changing my habits so my program is littered with inconsistencies which I then have to go back and correct because I forgot to put underscores in. Is this necessary? Helpful? If so, why?
    Last edited by dali_lama_2k; 02-04-2019, 11:34 AM. Reason: edited for clarity and adding of tags


  • #2
    The way I structure things I mostly use spaces, but I use underscores for doing groups of tags with different steps in the sequence. For instance I might have my on/off tag for something be called "Valve A - CMore" so I know that bit gets turned on and off from my HMI. But then the sequence for valve A I will have stuff like ValveA_step1, ValveA_step2. I just helps me differentiate between tag uses.

    Comment



    • #3
      So the underscores are used as a function of writing style and organization for the programmer, and do not serve a direct purpose. Your answer interpreted my question precisely; thank you! I'm currently using them to differentiate between a Boolean tag and an I/O (physical) tag, in order to minimize tag name length and to speed up writing the program through the tag name drop-down list population as I type in the text box.

      Comment



      • #4
        I think it is best practice to use underscores. Having space would indicate to me two or more tagnames. Having a hyphen would read to me as subtraction. Keepin with underscores (OrCamelNotation) also keeps in check with other software suites, programming launguages, etc.

        Comment



        • #5
          Underscores were a staple of C programming, where spaces are not allowed in symbol names. C++ brought us the blessing of CamelCase and most of us never looked back. There was nothing in C that limited the use of capital letters, but folks tend to write the way they are taught. I write mostly in C++ now, but in the rare case I write C, I always use camel case.

          Virtually every high level language parser will chuck a wobbly over spaces in symbols, so I would tend to avoid it even if tolerated.

          Comment



          • #6
            Originally posted by BobO View Post
            .
            Virtually every high level language parser will chuck a wobbly over spaces in symbols, so I would tend to avoid it even if tolerated.
            Spaces in tagnames also obscure where one tagname ends and the next begins.
            Try reading a math instruction formula in a project in which spaces are used in tagnames.

            Comment



            • #7
              Originally posted by kewakl View Post

              Spaces in tagnames also obscure where one tagname ends and the next begins.
              Try reading a math instruction formula in a project in which spaces are used in tagnames.
              If you use an tag with an underscore in the math instruction, it looks like you have a space in there anyway:

              Click image for larger version

Name:	underscore.png
Views:	78
Size:	2.9 KB
ID:	120477

              ^^^^^^^^none of those are spaces in tagnames.

              Comment



              • #8
                Originally posted by MikeN View Post

                If you use an tag with an underscore in the math instruction, it looks like you have a space in there anyway:

                Click image for larger version

Name:	underscore.png
Views:	78
Size:	2.9 KB
ID:	120477

                ^^^^^^^^none of those are spaces in tagnames.
                Understood. However, I wasn't specifically targeting the PAC Suite.

                Comment



                • #9
                  If you use the CamelBack format and you import the tags into CMore then the whole tagname gets converted to Uppercase.

                  Comment



                  • #10
                    Originally posted by Levi G View Post
                    If you use the CamelBack format and you import the tags into CMore then the whole tagname gets converted to Uppercase.
                    True, but CMore uses all caps for all of its tags, regardless. I'm so glad that I 'discovered' the ability to import tags to CMore; I was gearing up for an onerous day of tag transcription before I decided to give it another look lol. Thanks for the feedback, everyone!

                    Comment



                    • #11
                      Originally posted by BobO View Post

                      Virtually every high level language parser will chuck a wobbly over spaces in symbols, so I would tend to avoid it even if tolerated.
                      Spaces in symbols are an abomination!

                      Interesting fact; while the MSDOS command.con would not allow spaces in file/ path names, however the underling DOS apparently either used null terminated strings or maybe just a fixed 11 (8+3) byte field and didn't much care what characters were in a name, so an application program could create files that could not be deleted from the command line (and of course the people writing such programs wouldn't have provided their own delete function, because reasons)
                      Then Apple came along and allowed " in a file name! WTF ?
                      I still remember getting file sent from a mac to my Windows based RIP named something like <print 20" wide> Argg, what is wrong with you people?!

                      copy copy of backup file What_could_go_wrong



                      Comment

                      Working...
                      X