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. Variable naming

Variable naming

Scheduled Pinned Locked Moved The Lounge
csharpasp-netquestion
13 Posts 11 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.
  • S Offline
    S Offline
    sacoskun
    wrote on last edited by
    #1

    I'm an ASP.NET developer. I would like to ask about a coding style standard. I have a button and click event of that button, what would you suggest for naming? a. XXButton, XXButton_Click b. xXButton, xXButton_Click c. xXButton, XXButton_Click d. ButtonXX, ButtonXX_Click e. ButtonXX, buttonXX_Click f. buttonXX, buttonXX_Click Which one do you prefer?

    J J V R P 9 Replies Last reply
    0
    • S sacoskun

      I'm an ASP.NET developer. I would like to ask about a coding style standard. I have a button and click event of that button, what would you suggest for naming? a. XXButton, XXButton_Click b. xXButton, xXButton_Click c. xXButton, XXButton_Click d. ButtonXX, ButtonXX_Click e. ButtonXX, buttonXX_Click f. buttonXX, buttonXX_Click Which one do you prefer?

      J Offline
      J Offline
      Justin Perez
      wrote on last edited by
      #2

      The way I usually roll is hungarian notation(I think that's what it's called). EX: btnRebootSystem for a button lstExclusions txtMessageToSend .... You get the idea... You get a quick rundown of the control you are dealing with in code, and a longer explanation of what it does. I recommend that over your examples

      I get all the news I need from the weather report - Paul Simon (from "The Only Living Boy in New York")

      D 1 Reply Last reply
      0
      • S sacoskun

        I'm an ASP.NET developer. I would like to ask about a coding style standard. I have a button and click event of that button, what would you suggest for naming? a. XXButton, XXButton_Click b. xXButton, xXButton_Click c. xXButton, XXButton_Click d. ButtonXX, ButtonXX_Click e. ButtonXX, buttonXX_Click f. buttonXX, buttonXX_Click Which one do you prefer?

        J Offline
        J Offline
        J4amieC
        wrote on last edited by
        #3

        My personal preference is a.

        --- How to get answers to your questions[^]

        1 Reply Last reply
        0
        • S sacoskun

          I'm an ASP.NET developer. I would like to ask about a coding style standard. I have a button and click event of that button, what would you suggest for naming? a. XXButton, XXButton_Click b. xXButton, xXButton_Click c. xXButton, XXButton_Click d. ButtonXX, ButtonXX_Click e. ButtonXX, buttonXX_Click f. buttonXX, buttonXX_Click Which one do you prefer?

          V Offline
          V Offline
          Vasudevan Deepak Kumar
          wrote on last edited by
          #4

          http://weblogs.asp.net/scottdockendorf/archive/2005/01/26/361020.aspx[^]

          Vasudevan Deepak Kumar Personal Homepage Tech Gossips

          1 Reply Last reply
          0
          • S sacoskun

            I'm an ASP.NET developer. I would like to ask about a coding style standard. I have a button and click event of that button, what would you suggest for naming? a. XXButton, XXButton_Click b. xXButton, xXButton_Click c. xXButton, XXButton_Click d. ButtonXX, ButtonXX_Click e. ButtonXX, buttonXX_Click f. buttonXX, buttonXX_Click Which one do you prefer?

            R Offline
            R Offline
            Rohde
            wrote on last edited by
            #5

            Well I use for example UploadVideoButton and UploadVideoButton_Click that is also the way it should be done, all other ways are just stupid. ;);):)


            "When you have made evil the means of survival, do not expect men to remain good. Do not expect them to stay moral and lose their lives for the purpose of becoming the fodder of the immoral. Do not expect them to produce, when production is punished and looting rewarded. Do not ask, `Who is destroying the world?' You are."
            -Atlas Shrugged, Ayn Rand

            E 1 Reply Last reply
            0
            • S sacoskun

              I'm an ASP.NET developer. I would like to ask about a coding style standard. I have a button and click event of that button, what would you suggest for naming? a. XXButton, XXButton_Click b. xXButton, xXButton_Click c. xXButton, XXButton_Click d. ButtonXX, ButtonXX_Click e. ButtonXX, buttonXX_Click f. buttonXX, buttonXX_Click Which one do you prefer?

              P Offline
              P Offline
              Pete OHanlon
              wrote on last edited by
              #6

              I prefer name mangling? Let the developer guess what the click event will be: Is it x or aaa?

              Deja View - the feeling that you've seen this post before.

              V 1 Reply Last reply
              0
              • P Pete OHanlon

                I prefer name mangling? Let the developer guess what the click event will be: Is it x or aaa?

                Deja View - the feeling that you've seen this post before.

                V Offline
                V Offline
                Vasudevan Deepak Kumar
                wrote on last edited by
                #7

                Pete O`Hanlon wrote:

                name mangling

                But that is good during release right? Since mangled names hinder easier debugging.

                Vasudevan Deepak Kumar Personal Homepage Tech Gossips

                1 Reply Last reply
                0
                • J Justin Perez

                  The way I usually roll is hungarian notation(I think that's what it's called). EX: btnRebootSystem for a button lstExclusions txtMessageToSend .... You get the idea... You get a quick rundown of the control you are dealing with in code, and a longer explanation of what it does. I recommend that over your examples

                  I get all the news I need from the weather report - Paul Simon (from "The Only Living Boy in New York")

                  D Offline
                  D Offline
                  daniilzol
                  wrote on last edited by
                  #8

                  I prefer that too since if there are many widgets on a form I may forget exact name, but as long as I remember the type of a widget I'll simply write btn... and intelisense will give me nice sorted list of all buttons I have on the form, otherwise you'd have to guess is it RebootSystem or SystemReboot or Restart, or any of the other half-a-dozen variations etc, etc, etc. Events will simply have _action appended at the end, for example btnOK_click (which is default in vs200x), nice and self-explanatory.

                  1 Reply Last reply
                  0
                  • S sacoskun

                    I'm an ASP.NET developer. I would like to ask about a coding style standard. I have a button and click event of that button, what would you suggest for naming? a. XXButton, XXButton_Click b. xXButton, xXButton_Click c. xXButton, XXButton_Click d. ButtonXX, ButtonXX_Click e. ButtonXX, buttonXX_Click f. buttonXX, buttonXX_Click Which one do you prefer?

                    E Offline
                    E Offline
                    El Corazon
                    wrote on last edited by
                    #9

                    button_button_whos_clicked_the_button

                    _________________________ Asu no koto o ieba, tenjo de nezumi ga warau. Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)

                    1 Reply Last reply
                    0
                    • R Rohde

                      Well I use for example UploadVideoButton and UploadVideoButton_Click that is also the way it should be done, all other ways are just stupid. ;);):)


                      "When you have made evil the means of survival, do not expect men to remain good. Do not expect them to stay moral and lose their lives for the purpose of becoming the fodder of the immoral. Do not expect them to produce, when production is punished and looting rewarded. Do not ask, `Who is destroying the world?' You are."
                      -Atlas Shrugged, Ayn Rand

                      E Offline
                      E Offline
                      El Corazon
                      wrote on last edited by
                      #10

                      Rohde wrote:

                      UploadVideoButton

                      Mine too, all jokes aside. If I don't name the widgets for their functions, I'll eventually forget that Button1 operates launch and Button2 operates self-destruct.... kind of important not to mix those two... ;) Seriously though, naming for function is smart, buttonaa or abuttonxxx tells you nothing (unless the latter is launching unmentionable videos).

                      _________________________ Asu no koto o ieba, tenjo de nezumi ga warau. Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)

                      1 Reply Last reply
                      0
                      • S sacoskun

                        I'm an ASP.NET developer. I would like to ask about a coding style standard. I have a button and click event of that button, what would you suggest for naming? a. XXButton, XXButton_Click b. xXButton, xXButton_Click c. xXButton, XXButton_Click d. ButtonXX, ButtonXX_Click e. ButtonXX, buttonXX_Click f. buttonXX, buttonXX_Click Which one do you prefer?

                        D Offline
                        D Offline
                        David Crow
                        wrote on last edited by
                        #11

                        Why type so much when you don't have to: g. b, bc


                        "A good athlete is the result of a good and worthy opponent." - David Crow

                        "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

                        1 Reply Last reply
                        0
                        • S sacoskun

                          I'm an ASP.NET developer. I would like to ask about a coding style standard. I have a button and click event of that button, what would you suggest for naming? a. XXButton, XXButton_Click b. xXButton, xXButton_Click c. xXButton, XXButton_Click d. ButtonXX, ButtonXX_Click e. ButtonXX, buttonXX_Click f. buttonXX, buttonXX_Click Which one do you prefer?

                          A Offline
                          A Offline
                          Al Beback
                          wrote on last edited by
                          #12

                          None of those. I like: x, x_Click where x = ok, cancel, save, etc.


                          Man is a marvelous curiosity ... he thinks he is the Creator's pet ... he even believes the Creator loves him; has a passion for him; sits up nights to admire him; yes and watch over him and keep him out of trouble. He prays to him and thinks He listens. Isn't it a quaint idea. - Mark Twain

                          1 Reply Last reply
                          0
                          • S sacoskun

                            I'm an ASP.NET developer. I would like to ask about a coding style standard. I have a button and click event of that button, what would you suggest for naming? a. XXButton, XXButton_Click b. xXButton, xXButton_Click c. xXButton, XXButton_Click d. ButtonXX, ButtonXX_Click e. ButtonXX, buttonXX_Click f. buttonXX, buttonXX_Click Which one do you prefer?

                            B Offline
                            B Offline
                            Brady Kelly
                            wrote on last edited by
                            #13

                            My usual is f.  I used to use pseudo-Hungarian only on UI elements, like btnXX, but I thought I'd make a clean break and adopt fashionable long variable names.  All my UI stuff I do like that now, so a textbox is 'textName' etc.

                            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