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. Not programming, but a preference question.

Not programming, but a preference question.

Scheduled Pinned Locked Moved The Lounge
questioncollaboration
93 Posts 34 Posters 1 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.
  • W Offline
    W Offline
    wizardzz
    wrote on last edited by
    #1

    var

    A big ugly word. I don't use them unless I really need to. Now I have a project to add to that another developer created. Cool. There are a lot of vars in here. Unavoidable, too. Now, I'm the head "developer" on this team, and basically have to know all code inside and out pretty darm well. So does it make me a dick to want to use some sort of Hungarian Notation* on these vars? [Editing for clarity] I do not mean adding var to the front, or necessarily the type (though that will be useful in some cases, that's why I mistakenly said HN) I meant using a short form abbreviation to signify what the hell the variable is for rather than just "Loc" "Cust" etc when there are many similar variables.

    A L S A P 19 Replies Last reply
    0
    • W wizardzz

      var

      A big ugly word. I don't use them unless I really need to. Now I have a project to add to that another developer created. Cool. There are a lot of vars in here. Unavoidable, too. Now, I'm the head "developer" on this team, and basically have to know all code inside and out pretty darm well. So does it make me a dick to want to use some sort of Hungarian Notation* on these vars? [Editing for clarity] I do not mean adding var to the front, or necessarily the type (though that will be useful in some cases, that's why I mistakenly said HN) I meant using a short form abbreviation to signify what the hell the variable is for rather than just "Loc" "Cust" etc when there are many similar variables.

      A Offline
      A Offline
      AspDotNetDev
      wrote on last edited by
      #2

      I don't see why not:

      var varAge = getAge();

      Thou mewling ill-breeding pignut!

      T 1 Reply Last reply
      0
      • W wizardzz

        var

        A big ugly word. I don't use them unless I really need to. Now I have a project to add to that another developer created. Cool. There are a lot of vars in here. Unavoidable, too. Now, I'm the head "developer" on this team, and basically have to know all code inside and out pretty darm well. So does it make me a dick to want to use some sort of Hungarian Notation* on these vars? [Editing for clarity] I do not mean adding var to the front, or necessarily the type (though that will be useful in some cases, that's why I mistakenly said HN) I meant using a short form abbreviation to signify what the hell the variable is for rather than just "Loc" "Cust" etc when there are many similar variables.

        A Offline
        A Offline
        AspDotNetDev
        wrote on last edited by
        #3

        If you are in the pacifier business, you might consider:

        var varBinks = getBinkyCount();

        Thou mewling ill-breeding pignut!

        T 1 Reply Last reply
        0
        • W wizardzz

          var

          A big ugly word. I don't use them unless I really need to. Now I have a project to add to that another developer created. Cool. There are a lot of vars in here. Unavoidable, too. Now, I'm the head "developer" on this team, and basically have to know all code inside and out pretty darm well. So does it make me a dick to want to use some sort of Hungarian Notation* on these vars? [Editing for clarity] I do not mean adding var to the front, or necessarily the type (though that will be useful in some cases, that's why I mistakenly said HN) I meant using a short form abbreviation to signify what the hell the variable is for rather than just "Loc" "Cust" etc when there are many similar variables.

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

          I do not see why people get hung up on var. (I am quite certain I will ge downvoted for this post) IMO it is cleaner.

          namespace ThirdPartynamespace
          {
          class RequiredComponent
          {
          }
          }

          ...

          namespace DifferentThirdPartyNamespace
          {
          class RequiredComponent
          {
          }
          }

          namespace Local
          {
          class Thingamajig
          {
          var component = new ThirdPartyNameSpace.RequiredComponent();
          var diffComponent = new DifferentThirdPartyNameSpace.RequiredComponent();
          //vs

            ThirdPartyNameSpace.RequiredComponent ewComponent = new ThirdPartyNameSpace.RequiredComponent();
          
           DifferentThirdPartyNameSpace.RequiredComponent ewDiffComponent = new DifferentThirdPartyNameSpace.RequiredComponent();
          

          }
          }

          Ok, so now you will say that is a rare case. Maybe it is but because this case happens (actually it happens to me alot but mostly because how I use namespaces), you should follow patterns being set. You may not be always worried about thread mishaps but you still program for it. Other reasons: Return object changes.

          Computers have been intelligent for a long time now. It just so happens that the program writers are about as effective as a room full of monkeys trying to crank out a copy of Hamlet.

          B W D F J 5 Replies Last reply
          0
          • W wizardzz

            var

            A big ugly word. I don't use them unless I really need to. Now I have a project to add to that another developer created. Cool. There are a lot of vars in here. Unavoidable, too. Now, I'm the head "developer" on this team, and basically have to know all code inside and out pretty darm well. So does it make me a dick to want to use some sort of Hungarian Notation* on these vars? [Editing for clarity] I do not mean adding var to the front, or necessarily the type (though that will be useful in some cases, that's why I mistakenly said HN) I meant using a short form abbreviation to signify what the hell the variable is for rather than just "Loc" "Cust" etc when there are many similar variables.

            S Offline
            S Offline
            Slacker007
            wrote on last edited by
            #5

            wizardzz wrote:

            So does it make me a dick to want to use some sort of Hungarian Notation on these vars?

            What would be the purpose of using the Hungarian notation?

            "the meat from that butcher is just the dogs danglies, absolutely amazing cuts of beef." - DaveAuld (2011)
            "No, that is just the earthly manifestation of the Great God Retardon." - Nagy Vilmos (2011) "It is the celestial scrotum of good luck!" - Nagy Vilmos (2011) "But you probably have the smoothest scrotum of any grown man" - Pete O'Hanlon (2012)

            W L 2 Replies Last reply
            0
            • S Slacker007

              wizardzz wrote:

              So does it make me a dick to want to use some sort of Hungarian Notation on these vars?

              What would be the purpose of using the Hungarian notation?

              "the meat from that butcher is just the dogs danglies, absolutely amazing cuts of beef." - DaveAuld (2011)
              "No, that is just the earthly manifestation of the Great God Retardon." - Nagy Vilmos (2011) "It is the celestial scrotum of good luck!" - Nagy Vilmos (2011) "But you probably have the smoothest scrotum of any grown man" - Pete O'Hanlon (2012)

              W Offline
              W Offline
              wizardzz
              wrote on last edited by
              #6

              To help me understand what is being done, or rather, what is intended to be done. I guess they are poorly named variables to begin with, so that should be corrected first, and since almost every single variable is a var, it's taking quite some time to figure out why some choices were made. I should say that this is on top of some poorly written code that needs major re factoring, so that doesn't help.

              S OriginalGriffO L E A 5 Replies Last reply
              0
              • W wizardzz

                To help me understand what is being done, or rather, what is intended to be done. I guess they are poorly named variables to begin with, so that should be corrected first, and since almost every single variable is a var, it's taking quite some time to figure out why some choices were made. I should say that this is on top of some poorly written code that needs major re factoring, so that doesn't help.

                S Offline
                S Offline
                Slacker007
                wrote on last edited by
                #7

                How long have you examined this code? What is your time frame on this project? Possible refactoring...on some sections? Also, if you name everything with the prefix of var, then if you end up changing the data type then you will have to rename all the variables, I would think.

                "the meat from that butcher is just the dogs danglies, absolutely amazing cuts of beef." - DaveAuld (2011)
                "No, that is just the earthly manifestation of the Great God Retardon." - Nagy Vilmos (2011) "It is the celestial scrotum of good luck!" - Nagy Vilmos (2011) "But you probably have the smoothest scrotum of any grown man" - Pete O'Hanlon (2012)

                W 1 Reply Last reply
                0
                • S Slacker007

                  wizardzz wrote:

                  So does it make me a dick to want to use some sort of Hungarian Notation on these vars?

                  What would be the purpose of using the Hungarian notation?

                  "the meat from that butcher is just the dogs danglies, absolutely amazing cuts of beef." - DaveAuld (2011)
                  "No, that is just the earthly manifestation of the Great God Retardon." - Nagy Vilmos (2011) "It is the celestial scrotum of good luck!" - Nagy Vilmos (2011) "But you probably have the smoothest scrotum of any grown man" - Pete O'Hanlon (2012)

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

                  He is claiming he needs to know its type and does not know it because "var" was used. So he would keep var and add the system type as a prefix (i.e. Hungarian notation)

                  var iAge = GetAge();

                  Silly IMO. Why do you need to know the type. IDE is smart enough. It is better to name what it is for or add more meaning.

                  var ageOfUser = GetusersAge();

                  var ageSearch= GetAgeToSearchFor();

                  var ageConstraintMin = GetAgeConstraintMin();

                  Computers have been intelligent for a long time now. It just so happens that the program writers are about as effective as a room full of monkeys trying to crank out a copy of Hamlet.

                  E 1 Reply Last reply
                  0
                  • W wizardzz

                    To help me understand what is being done, or rather, what is intended to be done. I guess they are poorly named variables to begin with, so that should be corrected first, and since almost every single variable is a var, it's taking quite some time to figure out why some choices were made. I should say that this is on top of some poorly written code that needs major re factoring, so that doesn't help.

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

                    wizardzz wrote:

                    since almost every single variable is a var, it's taking quite some time to figure out why some choices were made

                    That is my main dislike of var - when you are trying to read the code, you have no idea what a variable is, or what you can do with it, without looking at some other bit of code and coming back. Explicit variable typing lets you know immediately what type it is and hence what you can do with it. Besides, it's lazy. "I don't want to think about this variable, it just want to get on with the interesting stuff".

                    Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water

                    "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

                    W S S 3 Replies Last reply
                    0
                    • W wizardzz

                      To help me understand what is being done, or rather, what is intended to be done. I guess they are poorly named variables to begin with, so that should be corrected first, and since almost every single variable is a var, it's taking quite some time to figure out why some choices were made. I should say that this is on top of some poorly written code that needs major re factoring, so that doesn't help.

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

                      wizardzz wrote:

                      I guess they are poorly named variables to begin with, so that should be corrected first

                      I would stop there. Name them correctly such that anyone can figure it out. What does switching var to a concrete type gain you? Did you forget you can mouse over. There is a reason that hungarian notation is not used.

                      Computers have been intelligent for a long time now. It just so happens that the program writers are about as effective as a room full of monkeys trying to crank out a copy of Hamlet.

                      W 1 Reply Last reply
                      0
                      • S Slacker007

                        How long have you examined this code? What is your time frame on this project? Possible refactoring...on some sections? Also, if you name everything with the prefix of var, then if you end up changing the data type then you will have to rename all the variables, I would think.

                        "the meat from that butcher is just the dogs danglies, absolutely amazing cuts of beef." - DaveAuld (2011)
                        "No, that is just the earthly manifestation of the Great God Retardon." - Nagy Vilmos (2011) "It is the celestial scrotum of good luck!" - Nagy Vilmos (2011) "But you probably have the smoothest scrotum of any grown man" - Pete O'Hanlon (2012)

                        W Offline
                        W Offline
                        wizardzz
                        wrote on last edited by
                        #11

                        Dang, maybe I should have clarified. I meant Hungarian Notation "style", not strictly varName, etc. Example:

                        var BeginDate = item.GetType().GetProperty("BeginDate");
                        var Locations = item.GetType().GetProperty("Locations");

                        I would prefer to be

                        var propBeginDate = item.GetType().GetProperty("BeginDate");
                        var propLocations = item.GetType().GetProperty("Locations");

                        or something like that. This is more of an example of what I meant. I guess I should have initially said, am I dick for changing variables to make more sense?

                        S T T I 4 Replies Last reply
                        0
                        • W wizardzz

                          var

                          A big ugly word. I don't use them unless I really need to. Now I have a project to add to that another developer created. Cool. There are a lot of vars in here. Unavoidable, too. Now, I'm the head "developer" on this team, and basically have to know all code inside and out pretty darm well. So does it make me a dick to want to use some sort of Hungarian Notation* on these vars? [Editing for clarity] I do not mean adding var to the front, or necessarily the type (though that will be useful in some cases, that's why I mistakenly said HN) I meant using a short form abbreviation to signify what the hell the variable is for rather than just "Loc" "Cust" etc when there are many similar variables.

                          A Offline
                          A Offline
                          Andy Brummer
                          wrote on last edited by
                          #12

                          Don't you use visual studio? Between hovering over a variable and code completion I don't even think about checking the declaration to find the type of the variable. If they were needlessly using dynamic that would be more of a pain, but var isn't that big of a deal unless it is something like the following.

                          var what = 1, are = 1f, you = 1u, thinking = 1m, here = 1d, haha = 1UL;

                          Curvature of the Mind now with 3D

                          1 Reply Last reply
                          0
                          • W wizardzz

                            To help me understand what is being done, or rather, what is intended to be done. I guess they are poorly named variables to begin with, so that should be corrected first, and since almost every single variable is a var, it's taking quite some time to figure out why some choices were made. I should say that this is on top of some poorly written code that needs major re factoring, so that doesn't help.

                            E Offline
                            E Offline
                            Espen Harlinn
                            wrote on last edited by
                            #13

                            I use Refactor! Pro[^]. Right click on the offending var declared varable and choose 'Make explicit' and there I have a decently declared varable. I'm pretty sure other refactoring tools have a similar feature.

                            Espen Harlinn Principal Architect, Software - Goodtech Projects & Services AS My LinkedIn Profile

                            J T I 3 Replies Last reply
                            0
                            • L Lost User

                              wizardzz wrote:

                              I guess they are poorly named variables to begin with, so that should be corrected first

                              I would stop there. Name them correctly such that anyone can figure it out. What does switching var to a concrete type gain you? Did you forget you can mouse over. There is a reason that hungarian notation is not used.

                              Computers have been intelligent for a long time now. It just so happens that the program writers are about as effective as a room full of monkeys trying to crank out a copy of Hamlet.

                              W Offline
                              W Offline
                              wizardzz
                              wrote on last edited by
                              #14

                              I think we had a misunderstanding regarding your first response. I didn't mean Hungarian Notation in the strict sense. I meant as a "style" type. I debated using HN in my first post even. See my response to Steve here: http://www.codeproject.com/Lounge.aspx?msg=4281501#xx4281501xx[^]

                              L 1 Reply Last reply
                              0
                              • W wizardzz

                                Dang, maybe I should have clarified. I meant Hungarian Notation "style", not strictly varName, etc. Example:

                                var BeginDate = item.GetType().GetProperty("BeginDate");
                                var Locations = item.GetType().GetProperty("Locations");

                                I would prefer to be

                                var propBeginDate = item.GetType().GetProperty("BeginDate");
                                var propLocations = item.GetType().GetProperty("Locations");

                                or something like that. This is more of an example of what I meant. I guess I should have initially said, am I dick for changing variables to make more sense?

                                S Offline
                                S Offline
                                Slacker007
                                wrote on last edited by
                                #15

                                wizardzz wrote:

                                am I dick for changing variables to make more sense?

                                no. variables, should always make sense. All naming should make sense. Go for it. :)

                                "the meat from that butcher is just the dogs danglies, absolutely amazing cuts of beef." - DaveAuld (2011)
                                "No, that is just the earthly manifestation of the Great God Retardon." - Nagy Vilmos (2011) "It is the celestial scrotum of good luck!" - Nagy Vilmos (2011) "But you probably have the smoothest scrotum of any grown man" - Pete O'Hanlon (2012)

                                W 1 Reply Last reply
                                0
                                • W wizardzz

                                  To help me understand what is being done, or rather, what is intended to be done. I guess they are poorly named variables to begin with, so that should be corrected first, and since almost every single variable is a var, it's taking quite some time to figure out why some choices were made. I should say that this is on top of some poorly written code that needs major re factoring, so that doesn't help.

                                  A Offline
                                  A Offline
                                  Andy Brummer
                                  wrote on last edited by
                                  #16

                                  If the variable names are difficult to understand, I'd go ahead and rename them and add comments as long as I can defend my reasoning. When I do that, I try to do two checkins one for refactoring and one for actual functionality changes so it's easier to separate the two.

                                  Curvature of the Mind now with 3D

                                  W 1 Reply Last reply
                                  0
                                  • S Slacker007

                                    wizardzz wrote:

                                    am I dick for changing variables to make more sense?

                                    no. variables, should always make sense. All naming should make sense. Go for it. :)

                                    "the meat from that butcher is just the dogs danglies, absolutely amazing cuts of beef." - DaveAuld (2011)
                                    "No, that is just the earthly manifestation of the Great God Retardon." - Nagy Vilmos (2011) "It is the celestial scrotum of good luck!" - Nagy Vilmos (2011) "But you probably have the smoothest scrotum of any grown man" - Pete O'Hanlon (2012)

                                    W Offline
                                    W Offline
                                    wizardzz
                                    wrote on last edited by
                                    #17

                                    I guess I took my frustration with vaguely named vars out on var itself. I don't necessarily hate them, I see why they are used and necessary. I know I can look like a dick for asking them not to be used. However I should be frustrated at the right thing for the right reason. There is literally a declaration that looks like

                                    var loc = ...

                                    when it's being used as:

                                    Locations.Location loc = ....

                                    Neither of these are nice. I should clarify, there are about 4 different variables referring to different types of locations. Each named very similar/just abbreviated.

                                    L 1 Reply Last reply
                                    0
                                    • A Andy Brummer

                                      If the variable names are difficult to understand, I'd go ahead and rename them and add comments as long as I can defend my reasoning. When I do that, I try to do two checkins one for refactoring and one for actual functionality changes so it's easier to separate the two.

                                      Curvature of the Mind now with 3D

                                      W Offline
                                      W Offline
                                      wizardzz
                                      wrote on last edited by
                                      #18

                                      Yeah, I did some quick functional refactoring right off the bat (I freaked out on a nasty if/else tree). I think next will be the namings.

                                      1 Reply Last reply
                                      0
                                      • W wizardzz

                                        var

                                        A big ugly word. I don't use them unless I really need to. Now I have a project to add to that another developer created. Cool. There are a lot of vars in here. Unavoidable, too. Now, I'm the head "developer" on this team, and basically have to know all code inside and out pretty darm well. So does it make me a dick to want to use some sort of Hungarian Notation* on these vars? [Editing for clarity] I do not mean adding var to the front, or necessarily the type (though that will be useful in some cases, that's why I mistakenly said HN) I meant using a short form abbreviation to signify what the hell the variable is for rather than just "Loc" "Cust" etc when there are many similar variables.

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

                                        IT doesn't make you a dick.

                                        *pre-emptive celebratory nipple tassle jiggle* - Sean Ewington

                                        "Mind bleach! Send me mind bleach!" - Nagy Vilmos

                                        CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier

                                        T 1 Reply Last reply
                                        0
                                        • L Lost User

                                          He is claiming he needs to know its type and does not know it because "var" was used. So he would keep var and add the system type as a prefix (i.e. Hungarian notation)

                                          var iAge = GetAge();

                                          Silly IMO. Why do you need to know the type. IDE is smart enough. It is better to name what it is for or add more meaning.

                                          var ageOfUser = GetusersAge();

                                          var ageSearch= GetAgeToSearchFor();

                                          var ageConstraintMin = GetAgeConstraintMin();

                                          Computers have been intelligent for a long time now. It just so happens that the program writers are about as effective as a room full of monkeys trying to crank out a copy of Hamlet.

                                          E Offline
                                          E Offline
                                          Espen Harlinn
                                          wrote on last edited by
                                          #20

                                          I agree on the importance of good naming, and I'm pretty sure wizardzz does too. I stopped using hungarian notation more than 10 years ago, but I still prefer variables not to be declared using var. I know that the IDE provides great help for determining the type of a variable, but when you have large amounts of code that you have to wade through, I've found that it helps that the variables are fully declared.

                                          Espen Harlinn Principal Architect, Software - Goodtech Projects & Services AS My LinkedIn Profile

                                          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