Coffeehouse Post

Single Post Permalink

View Thread: How are you using Tuple in code?
  • User profile image

    , exoteric wrote


    For simple things like coordinate sets tuples can be fine (although one wonders what their performance will be with Tuple being implemented as a reference type).

    Inefficient during allocation and efficient when passed as arguments. Always a trade-off.

    The question is whether the syntactic overhead of the object literal makes the code harder to easier to read. If a tuple is used locally in a function for some purpose but is not passed around then it can also be appropriate but then again, one could also just use two or more local variables for that. The more I think of them, the less I like tuples. They are often ambiguous constructs.

    If the objects in question aren't going to be passed around, anonymous types are far better at self-documenting.