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 2 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.
  • J jim lahey

    the thing that tells me that it's an implicitly typed local variable is the keyword var. I've got a VS extension (can't remember which one, sorry) that tells me the exact type when I hover over it with the mouse. As for naming conventions, I'm of the opinion that the name should semantically express the usage, so this would be totally fine with me:

    var count = 0;

    I can tell from the name what it's there for and by the assignment I can tell it's an int. I understand that some people might get confused by this:

    var count = someObject.GetCount();

    But all the above example means is that the above *might* be a short or long, and you can mouseover the method call in the assignment if you're desperate to know the exact type you're assigning. It's a whole number of some sort. If you're assigning anything other than int, short or long from a method called GetCount(), your method naming is wrong. Using a single byte to return a count is a bit of a special case which is why I haven't mentioned it. I've also never encountered a need to do so, incidentally. For some reason I get quite annoyed when people claim using var is bad practice because it introduces bugs to the code or don't get the fact that it's not the same as dynamic typing because they think it's the same as JavaScript. var works just fine, it means I don't repeat myself all over the place and is statically typed which means it won't even compile if I've done something wrong.

    I Offline
    I Offline
    Ilka Guigova
    wrote on last edited by
    #69

    I agree with Jim. It's too bad that it seems so easy to confuse and make developers feel insecure with code. We spend more time looking for crutches than understanding the code abstractions and how to use them to our benefit.

    I would imagine if you could understand Morse Code, a tap dancer would drive you crazy. [Mitch Hedberg (American Comedian, 1968-2005)]

    1 Reply Last reply
    0
    • F Fabio Franco

      Richard Deeming wrote:

      // Oh, wait - it's hidden in a "using" statement somewhere else in the file.

      Visual Studio: Right click -> Go to Definition Printed: It's the first thing you gonna see. Anyways, the worse case scenario here is when you find the necessity to fully qualify types for when you have same named classes over different namespaces within the same file. You gotta admit this is very rare. It happened to me only once with the Color and Report class. The latter was my mistake to use such a generic and and not descriptive class name on a big solution.

      To alcohol! The cause of, and solution to, all of life's problems - Homer Simpson ---- Our heads are round so our thoughts can change direction - Francis Picabia

      Richard DeemingR Offline
      Richard DeemingR Offline
      Richard Deeming
      wrote on last edited by
      #70

      Fabio Franco wrote:

      Visual Studio:
      Right click -> Go to Definition

      Yeah, that doesn't interfere with "sweeping the code to understand its purpose" at all! ;P It's easier to scan a "var x = new RealName()" statement than a "AliasedName x = new AliasedName()" statement.


      "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

      "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

      F 1 Reply Last reply
      0
      • F Fabio Franco

        Yeah, I know, case sensitiveness typo on namespace, the ellipses... Way out of the scope of this discussion

        To alcohol! The cause of, and solution to, all of life's problems - Homer Simpson ---- Our heads are round so our thoughts can change direction - Francis Picabia

        B Offline
        B Offline
        BillWoodruff
        wrote on last edited by
        #71

        Hi Fabio, The two only really important errors relate to the incorrect usage of 'var: which is exactly what this topic is about ! best,Bill

        "The greatest mystery is not that we have been flung at random between the profusion of matter and of the stars, but that within this prison we can draw from ourselves images powerful enough to deny our nothingness." Andre Malraux

        F 1 Reply Last reply
        0
        • B BillWoodruff

          Hi Fabio, The two only really important errors relate to the incorrect usage of 'var: which is exactly what this topic is about ! best,Bill

          "The greatest mystery is not that we have been flung at random between the profusion of matter and of the stars, but that within this prison we can draw from ourselves images powerful enough to deny our nothingness." Andre Malraux

          F Offline
          F Offline
          Fabio Franco
          wrote on last edited by
          #72

          Wouldn't it be easier then if you would just elaborate without everyone having to compile the code to understand what you are talking about?

          To alcohol! The cause of, and solution to, all of life's problems - Homer Simpson ---- Our heads are round so our thoughts can change direction - Francis Picabia

          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.

            S Offline
            S Offline
            satovey
            wrote on last edited by
            #73

            Correct me if I'm wrong in my inference but it sounds like your saying that the code is not properly commented. If that is the case then the answer is clearly no. On the other hand, you could simply add comments that inform you what the various vars are intended to accomplish and then change variable names from there. By commenting first, you are less likely to change a variable name that accomplishes nothing more than blowing the whole program up. Then again, you already knew that didn't you? Scott A. Tovey

            1 Reply Last reply
            0
            • L Lost User

              Hmmm pretty sure it is fine. For one they are not subclasses. They are classes within a namespace. This is a common confliction when working with many groups or using external resources, E.g Company a has "Camera" in their library as well as company B. So we end up with CompanyA.Camera And CompanyB.Camera For objects. That was actually the point that you must then call out the whole namespace multiple times. Or am I missing something that you are pointing out?

              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 Offline
              B Offline
              BillWoodruff
              wrote on last edited by
              #74

              Yes, esteemed colleague, Colin, you are missing something, and it's an understanding of how you can "legally" use 'var. Since the use of 'var is a major focus of this thread, I feel that's important. I would never have commented on your code based solely on errors in spelling. And, the comment on two classes with duplicate names was meant as a "lightweight" suggestion, not an attack. Surely it is not too much to ask for anyone who posts code, even here on the Lounge, to compile it, and see if it compiles ? Meanwhile, may the hair-trigger fingered down-voters (and I don't mean you) just keep having at me, because I will say what I see, and the compiler (VS 2012 RC in this case) reports as errors :) best, Bill

              "The greatest mystery is not that we have been flung at random between the profusion of matter and of the stars, but that within this prison we can draw from ourselves images powerful enough to deny our nothingness." Andre Malraux

              L 1 Reply Last reply
              0
              • T TheGreatAndPowerfulOz

                wizardzz wrote:

                propBeginDate

                why "prop"? The "type" or "what it is" is already part of the name. BeginDate

                If your actions inspire others to dream more, learn more, do more and become more, you are a leader." - John Quincy Adams
                You must accept one of two basic premises: Either we are alone in the universe, or we are not alone in the universe. And either way, the implications are staggering” - Wernher von Braun

                S Offline
                S Offline
                Sasha Laurel
                wrote on last edited by
                #75

                Actually you should check again since I don't think that BeginDate is a DateTime object at all, but a PropertyInfo object instead. I think its a perfect example. propBeginDate

                1 Reply Last reply
                0
                • OriginalGriffO OriginalGriff

                  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

                  S Offline
                  S Offline
                  Sasha Laurel
                  wrote on last edited by
                  #76

                  I couldn't agree with you more. I've never once come back on my old code and exclaimed "Why in the world was I so explicit!?", though I have wondered the contrary on some occasions.

                  1 Reply Last reply
                  0
                  • I IAbstract

                    I'm not near as stringent on the use of `var`. If my data types are short - e.g., string, int, List(Of T) - I use the explicit syntax for declaring the type. On the other hand, something like

                    Dictionary>

                    ...damned right I'm using `var`. It's up to the developer to make sure the variable name is meaningful - not the declaration of the data type. Yes, be responsible with the use of `var`. `var` is necessary in a few cases - as with LINQ and anonymous types. Make sure if you want an `IFoo` from a method that returns `Foo` that you cast it:

                    var foo = GetFoo() as IFoo;

                    // where GetFoo():
                    Foo GetFoo() {
                    return new Foo();
                    }

                    // and
                    class Foo : IFoo { }

                    I certainly don't recommend leaving fate in the hands of `var`. Overuse is abuse. And abusing `var` is downright lazy. But I wouldn't get that worked up about it - maybe. :-D

                    M Offline
                    M Offline
                    Mike Poz
                    wrote on last edited by
                    #77

                    Sadly there are tools like ReSharper that are required use in some shops that nag you to death about using "var" in place of strongly typed declarations. Yes, I turn off that in my settings but some other developer will come behind me and change all my code in my tools to use "var" everywhere. I'd love to meet the person who created that rule in ReSharper and punch them in the face. Seriously.

                    Mike Poz

                    1 Reply Last reply
                    0
                    • L Lost User

                      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.

                      J Offline
                      J Offline
                      jschell
                      wrote on last edited by
                      #78

                      Collin Jasnoch wrote:

                      Return object changes.

                      If you have a lot of code which would make that a valid rational then I would suspect something is wrong with your code/design.

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

                        M Offline
                        M Offline
                        Member 4608898
                        wrote on last edited by
                        #79

                        Why not just write in javascript: everything is declared as var; same as dim in vbscript. :-D

                        1 Reply Last reply
                        0
                        • F Fabio Franco

                          See how var can be a source of confusion?

                          To alcohol! The cause of, and solution to, all of life's problems - Homer Simpson ---- Our heads are round so our thoughts can change direction - Francis Picabia

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

                          No. I do not as I do not find it confusing :)

                          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.

                          1 Reply Last reply
                          0
                          • F Fabio Franco

                            Collin Jasnoch wrote:

                            var component = new ThirdPartyNameSpace.RequiredComponent(); var diffComponent = new DifferentThirdPartyNameSpace.RequiredComponent();

                            I read this and thought: "What the hell is the type returned by this methods?" "Oh wait, these are not methods, these are fully qualified types." Can you picture the ammount of unnecessary confusion created by this code when someone else try to read it? Or even your self after sometime? This easy to write and terrible to read. If you inherit a code that has a lot of vars good luck sweeping the code to understand its purpose. If you have a printed copy of the code, well then there is no way to understand the code.

                            Collin Jasnoch wrote:

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

                            That's what the "#using" directive is for, then you would have:

                            RequiredComponent notEwAtAllComponent = new RequiredComponent()

                            Now you have a very readable code and intellisense made it not hard to type, magic heh? When looking at the code from a mostly left to right culture I can instantly identify the type being declared. Second, if you have components with same names and different namespaces, you can make it much shorter also with the "#using" directive: #using ThirdPartyNameSpace; #using diffNS = DifferentThirdPartyNameSpace;

                            diffNS.RequiredComponent diffComponent = diffNS.RequiredComponent();

                            Lastly, var should be used for anonymous types. That's the real good use of it and shouldn't be abused like I often see. Your particular example is a hell to review.

                            To alcohol! The cause of, and solution to, all of life's problems - Homer Simpson ---- Our heads are round so our thoughts can change direction - Francis Picabia

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

                            As was pointed out by others alias names are definitely not a solution to the problem. In fact they are worse, IMO (maybe I am alone there though)

                            Fabio Franco wrote:

                            Can you picture the ammount of unnecessary confusion created by this code when someone else try to read it? Or even your self after sometime?

                            Simply put no I do not. A good programmer does not need the definition of the type to leave knowledge of what is happening. For example:

                            var saleId = GetActiveSaleId();
                            if(Customer.Sales.Contains(saleId))
                            {
                            //run some code
                            }

                            Do you care what saleId is? Does it really matter if it is int or a custom object? It shouldn't. Under the thought of I must know the type programmers do stuff like this.

                            IEnumerable<DataWarehouse.Sales> sCollection = CustomerCollection.GetActiveCustomer().Sales;
                            int id = ActiveSale.GetId();
                            ...

                            if(sCollection.Contains(id))
                            {
                            //run same code
                            }

                            The first has a clean if statement. I need not know what the actual objects are and no exactly what is going on. The later I am immediately confused as I am unsure what sCollection is or what I am checking with. You see that the definition has nothing to do with clarity. Maybe my brain works different. I have used languages that do not have concrete definition (e.g. Ruby) and have worked in teams that demanded proper naming. I also demand it and hopefully you see why

                            Fabio Franco wrote:

                            If you inherit a code that has a lot of vars good luck sweeping the code to understand its purpose. If you have a printed copy of the code, well then there is no way to understand the code.

                            Again I have no problem sweeping "good" code that only uses vars. Using vars is irrelevant. I have swept code that did not even used vars and 'weeped' a little. I think you really drive my point with "copy of the code". One should be able to copy the code with out the definition and allow a reader to understand it. That is good code as it is transferable even out of the language then.

                            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.

                            F 1 Reply Last reply
                            0
                            • J jschell

                              Collin Jasnoch wrote:

                              Return object changes.

                              If you have a lot of code which would make that a valid rational then I would suspect something is wrong with your code/design.

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

                              Have you ever used third party libraries? Things do become obsolete and change. Doesn't even have to be "Third Party". Could be the actual framework itself. This seems to be your most common response to my posts. Most of the time you just don't even grasp the point. Which is again the case. You take a small example I give and use that to troll my posts claiming my code has bad design. Examples are examples. If I can show a simple case where it happens (see above) it fits. Either respond to the actual point or don't respond at all.

                              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.

                              J 1 Reply Last reply
                              0
                              • B BillWoodruff

                                Compile it, and look at the errors. best, Bill

                                "The greatest mystery is not that we have been flung at random between the profusion of matter and of the stars, but that within this prison we can draw from ourselves images powerful enough to deny our nothingness." Andre Malraux

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

                                Have you ever heard of pseudo code? My code was not given in a response to someones question about how to solve something. It was given in a response for showing why you should not do something. If you fail to grasp the difference and expect to find usable code in the lounge you are mistaken. I never claimed it was usable code. It got the point across did it not? Yet you ramble on about compile issues. Are you griping because the classes are not public? Are you griping because of typos? Are you griping because my methods do not exist? Who cares? How is this relevant at all to the topic at hand? Again, code was not given to correct an issue. It was given as a case to prove a point.

                                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.

                                1 Reply Last reply
                                0
                                • B BillWoodruff

                                  Yes, esteemed colleague, Colin, you are missing something, and it's an understanding of how you can "legally" use 'var. Since the use of 'var is a major focus of this thread, I feel that's important. I would never have commented on your code based solely on errors in spelling. And, the comment on two classes with duplicate names was meant as a "lightweight" suggestion, not an attack. Surely it is not too much to ask for anyone who posts code, even here on the Lounge, to compile it, and see if it compiles ? Meanwhile, may the hair-trigger fingered down-voters (and I don't mean you) just keep having at me, because I will say what I see, and the compiler (VS 2012 RC in this case) reports as errors :) best, Bill

                                  "The greatest mystery is not that we have been flung at random between the profusion of matter and of the stars, but that within this prison we can draw from ourselves images powerful enough to deny our nothingness." Andre Malraux

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

                                  Not sure why you would expect code given as an case on a topic to compile. Was not provided as a solution to any problem. Was not provided as a real code base even. It was a simple example. If you would like to explain my "illegal" usage of var then by all means explain away. Also, you are using a Beta product. I see errors in there that should not exist as its beta. Try this. When using XAML resources type "ResourceKey" as it prompts you. Then compile. Totally irrelvant to the topic at hand, I know. :rolleyes: P.S. I have not downvoted you. But I would presume the downvoters are doing so mostly because you are not actually posting what you are talking about. Why keep telling us to compile the pseudo-code? Why not just post the error you are seeing and explain why you think I incorrectly used 'var'?

                                  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.

                                  1 Reply Last reply
                                  0
                                  • L Lost User

                                    As was pointed out by others alias names are definitely not a solution to the problem. In fact they are worse, IMO (maybe I am alone there though)

                                    Fabio Franco wrote:

                                    Can you picture the ammount of unnecessary confusion created by this code when someone else try to read it? Or even your self after sometime?

                                    Simply put no I do not. A good programmer does not need the definition of the type to leave knowledge of what is happening. For example:

                                    var saleId = GetActiveSaleId();
                                    if(Customer.Sales.Contains(saleId))
                                    {
                                    //run some code
                                    }

                                    Do you care what saleId is? Does it really matter if it is int or a custom object? It shouldn't. Under the thought of I must know the type programmers do stuff like this.

                                    IEnumerable<DataWarehouse.Sales> sCollection = CustomerCollection.GetActiveCustomer().Sales;
                                    int id = ActiveSale.GetId();
                                    ...

                                    if(sCollection.Contains(id))
                                    {
                                    //run same code
                                    }

                                    The first has a clean if statement. I need not know what the actual objects are and no exactly what is going on. The later I am immediately confused as I am unsure what sCollection is or what I am checking with. You see that the definition has nothing to do with clarity. Maybe my brain works different. I have used languages that do not have concrete definition (e.g. Ruby) and have worked in teams that demanded proper naming. I also demand it and hopefully you see why

                                    Fabio Franco wrote:

                                    If you inherit a code that has a lot of vars good luck sweeping the code to understand its purpose. If you have a printed copy of the code, well then there is no way to understand the code.

                                    Again I have no problem sweeping "good" code that only uses vars. Using vars is irrelevant. I have swept code that did not even used vars and 'weeped' a little. I think you really drive my point with "copy of the code". One should be able to copy the code with out the definition and allow a reader to understand it. That is good code as it is transferable even out of the language then.

                                    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.

                                    F Offline
                                    F Offline
                                    Fabio Franco
                                    wrote on last edited by
                                    #85

                                    Collin Jasnoch wrote:

                                    Simply put no I do not. A good programmer does not need the definition of the type to leave knowledge of what is happening.

                                    Where did you get that from? Of course if you're developing an e-commerce application, that's the least of the worries. Now if you're developing an AI engine, or something that has hardcore business logic, then yes it matters. And also, you're not taking into consideration the fact that applications are not bug free, and several bugs happen from inappropriate assignments, and that sir is where having a type in a really clear view becomes important.

                                    Collin Jasnoch wrote:

                                    You see that the definition has nothing to do with clarity.

                                    I disagree with the point you made.

                                    Collin Jasnoch wrote:

                                    I have used languages that do not have concrete definition

                                    So have most of us, like javascript, it doesn't mean is a good thing. Then we will enter in a debate whether a strongly typed language is better. And to me is much, much better, that's why C# is my language of choice.

                                    Collin Jasnoch wrote:

                                    Using vars is irrelevant.

                                    Right, so you see no problem in var receiving a type that is returned by method like:

                                    var someCollection = configManager.GetConfigSettings();

                                    Now, tell me, do you have any idea what the var type is inferring? To me using vars is lazy and a bad habit. You can find var usage recommendation in microsoft documentation, I just can't find it now where, but I bet if you're interested, you'll find. And the recommendation is to use var other than anonymous type only if the team is in a common consensus with it. Actually the var keyword only came to be because of the necessity to infer types when LINQ was introduced

                                    Collin Jasnoch wrote:

                                    One should be able to copy the code with out the definition and allow a reader to understand it.

                                    I agree, but again, not everything is as simple as that. Having a general understanding reading the code because it has proper naming and all that stuff is simply a ground rule. Now, understanding the details, specially when using not so trivial types from things like base class libraries, marshaling and reflection, well, sorry, that won't be enough. I think you may not have gotten to the point to develo

                                    L 1 Reply Last reply
                                    0
                                    • Richard DeemingR Richard Deeming

                                      Fabio Franco wrote:

                                      Visual Studio:
                                      Right click -> Go to Definition

                                      Yeah, that doesn't interfere with "sweeping the code to understand its purpose" at all! ;P It's easier to scan a "var x = new RealName()" statement than a "AliasedName x = new AliasedName()" statement.


                                      "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

                                      F Offline
                                      F Offline
                                      Fabio Franco
                                      wrote on last edited by
                                      #86

                                      Richard Deeming wrote:

                                      Yeah, that doesn't interfere with "sweeping the code to understand its purpose" at all!

                                      You got me here :) Anyway, that's just a case

                                      To alcohol! The cause of, and solution to, all of life's problems - Homer Simpson ---- Our heads are round so our thoughts can change direction - Francis Picabia

                                      1 Reply Last reply
                                      0
                                      • L Lost User

                                        Have you ever used third party libraries? Things do become obsolete and change. Doesn't even have to be "Third Party". Could be the actual framework itself. This seems to be your most common response to my posts. Most of the time you just don't even grasp the point. Which is again the case. You take a small example I give and use that to troll my posts claiming my code has bad design. Examples are examples. If I can show a simple case where it happens (see above) it fits. Either respond to the actual point or don't respond at all.

                                        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.

                                        J Offline
                                        J Offline
                                        jschell
                                        wrote on last edited by
                                        #87

                                        Collin Jasnoch wrote:

                                        Things do become obsolete and change.
                                        Doesn't even have to be "Third Party". Could be the actual framework itself.

                                        That has nothing to do with the statement that I quoted. There a many, many ways in which new requirements can make changes necessary. The specific case that you mentioned is a small, small fraction of that.

                                        1 Reply Last reply
                                        0
                                        • F Fabio Franco

                                          Collin Jasnoch wrote:

                                          Simply put no I do not. A good programmer does not need the definition of the type to leave knowledge of what is happening.

                                          Where did you get that from? Of course if you're developing an e-commerce application, that's the least of the worries. Now if you're developing an AI engine, or something that has hardcore business logic, then yes it matters. And also, you're not taking into consideration the fact that applications are not bug free, and several bugs happen from inappropriate assignments, and that sir is where having a type in a really clear view becomes important.

                                          Collin Jasnoch wrote:

                                          You see that the definition has nothing to do with clarity.

                                          I disagree with the point you made.

                                          Collin Jasnoch wrote:

                                          I have used languages that do not have concrete definition

                                          So have most of us, like javascript, it doesn't mean is a good thing. Then we will enter in a debate whether a strongly typed language is better. And to me is much, much better, that's why C# is my language of choice.

                                          Collin Jasnoch wrote:

                                          Using vars is irrelevant.

                                          Right, so you see no problem in var receiving a type that is returned by method like:

                                          var someCollection = configManager.GetConfigSettings();

                                          Now, tell me, do you have any idea what the var type is inferring? To me using vars is lazy and a bad habit. You can find var usage recommendation in microsoft documentation, I just can't find it now where, but I bet if you're interested, you'll find. And the recommendation is to use var other than anonymous type only if the team is in a common consensus with it. Actually the var keyword only came to be because of the necessity to infer types when LINQ was introduced

                                          Collin Jasnoch wrote:

                                          One should be able to copy the code with out the definition and allow a reader to understand it.

                                          I agree, but again, not everything is as simple as that. Having a general understanding reading the code because it has proper naming and all that stuff is simply a ground rule. Now, understanding the details, specially when using not so trivial types from things like base class libraries, marshaling and reflection, well, sorry, that won't be enough. I think you may not have gotten to the point to develo

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

                                          You again have completely missed the point and your example proves it. In your example you show a definition of a variable but no usage. Do you know what happens when you do this in code? The compiler throws it away. It's useless so what's the point. My point is the usage of variables should make it clear what is happening. More often than not (yes even in AI) the type is irrelevant.

                                          if(entityID < otherEntityID)
                                          {
                                          //process
                                          }

                                          Why do you care if someObject is int, double, or a custom object the uses the < operator? You shouldn't. If you need to know that you really don't grasp SOC and OOP. The only thing you need to know is what should happen when the first is less than the second. The how it is implemented is only needed to be understood by the developer of the type be it code>int, double, or a custom object. FYI I have developed image process techniques, AI image processing, motion tracking, data regression, machine UIs, web clients, web MT, eCommerce modules, and much more.

                                          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.

                                          F 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