• Visitors can check out the Forum FAQ by clicking this link. You have to register before you can post: click the REGISTER link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. View our Forum Privacy Policy.
  • Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!

You are not logged in or you do not have permission to access this page. This could be due to one of several reasons:

  • You are not logged in. If you are already registered, fill in the form below to log in, or follow the "Sign Up" link to register a new account.
  • You may not have sufficient privileges to access this page. Are you trying to edit someone else's post, access administrative features or some other privileged system?
  • If you are trying to post, the administrator may have disabled your account, or it may be awaiting activation.

Previously on "Anyone else trying to keep up with all the newish .NET stuff?"

Collapse

  • DimPrawn
    replied
    Another gem seen in some code today.

    Code:
    if (Enumerable.Range(0,100).Contains(x)) { // do stuff }
    Checking if x >= 0 and <=100

    Leave a comment:


  • DimPrawn
    replied
    Originally posted by Jaws View Post
    I think you might have misunderstood that.

    "var" was put there to handle anonymous types - as a programmer you should know what those look like because they are limited to the body of a method. If you want one of those to escape your method (outside of closures) you're just dealing with the "object" type again and are going to need to use reflection to get at its properties.

    I use "var" all the time too, do not see the need to mention the type twice when you're creating an object. I'm a bit more explicit with declarations when something is being returned from a method however.

    When you declare a variable with "var" you cant just change its type like you can with a dynamic language - it's fixed due to C#'s static typing.
    Yes. To me, var means "I'm a lazy bugger. The compiler knows the type, the VS.NET knows the type, so why should I bother typing it in?"

    Leave a comment:


  • Jaws
    replied
    Originally posted by eek View Post
    var goes hand in hand with linq. It solves the issue where linq returns something that the programmer wasn't expecting.
    I think you might have misunderstood that.

    "var" was put there to handle anonymous types - as a programmer you should know what those look like because they are limited to the body of a method. If you want one of those to escape your method (outside of closures) you're just dealing with the "object" type again and are going to need to use reflection to get at its properties.

    I use "var" all the time too, do not see the need to mention the type twice when you're creating an object. I'm a bit more explicit with declarations when something is being returned from a method however.

    When you declare a variable with "var" you cant just change its type like you can with a dynamic language - it's fixed due to C#'s static typing.

    Leave a comment:


  • d000hg
    replied
    If it returns something I wasn't expecting, I'd rather know about it than have things merrily go on doing something I hadn't planned on!

    Leave a comment:


  • eek
    replied
    Originally posted by d000hg View Post
    Isn't that what interfaces are for?

    I suppose in C++ we already had part of that with default parameters, which never seemed to take on elsewhere. Though it wasn't a very elegant implementation... named+optional parameters I can see making sense.
    var goes hand in hand with linq. It solves the issue where linq returns something that the programmer wasn't expecting.

    Leave a comment:


  • d000hg
    replied
    Originally posted by eek View Post
    var is useful in a its usually x but occassionally could be y department.
    Isn't that what interfaces are for?

    likewise optional parameters just keep the code a bit neater you don't end up with 5 functions for variations of input.
    I suppose in C++ we already had part of that with default parameters, which never seemed to take on elsewhere. Though it wasn't a very elegant implementation... named+optional parameters I can see making sense.

    Leave a comment:


  • tranceporter
    replied
    I use implicit var and linq/lambdas all the time. Rest of the gibberish, I wash my hands of it

    Leave a comment:


  • eek
    replied
    Originally posted by d000hg View Post
    From that diagram I stopped following around 3.0... lambdas and LINQ can be very useful but I don't really like var and everything later is gibberish to me.
    var is useful in a its usually x but occassionally could be y department.

    likewise optional parameters just keep the code a bit neater you don't end up with 5 functions for variations of input.

    Leave a comment:


  • d000hg
    replied
    From that diagram I stopped following around 3.0... lambdas and LINQ can be very useful but I don't really like var and everything later is gibberish to me.

    Leave a comment:


  • DimPrawn
    replied


    I mean all the language bloat.

    Leave a comment:


  • VectraMan
    replied
    I can't decide if that's better or worse than C++'s hideous lambda syntax.

    Leave a comment:


  • TheDude
    replied
    Originally posted by d000hg View Post
    But what you consider a fancy short cut someone else might consider readable. I find this with C++ templates; to me it's hard to figure out as I learned templates as a useful language feature while those who learned to program using templates as a core programming paradigm see it very clearly.

    Off topic Bit did you Post a lot in Topcoder back in the Day?

    Leave a comment:


  • d000hg
    replied
    Originally posted by eek View Post
    I was talking about an equivalent perl program from years back being written at the software house I owned back in the late 90s

    When it comes to code I have a simple rule, readable and maintainable. Fancy short cuts take a back seat because when it goes wrong I want to be able to identify the fault, understand it and fix it in a hurry.
    But what you consider a fancy short cut someone else might consider readable. I find this with C++ templates; to me it's hard to figure out as I learned templates as a useful language feature while those who learned to program using templates as a core programming paradigm see it very clearly.

    Leave a comment:


  • doodab
    replied
    Code:
    };
    });
    }
    is an abomination. That should just never be allowed to happen. Perhaps some indenting would help.

    Leave a comment:


  • eek
    replied
    Originally posted by d000hg View Post
    I don't think you are, he's a contractor.
    I was talking about an equivalent perl program from years back being written at the software house I owned back in the late 90s

    When it comes to code I have a simple rule, readable and maintainable. Fancy short cuts take a back seat because when it goes wrong I want to be able to identify the fault, understand it and fix it in a hurry.

    Leave a comment:

Working...
X