Click here to Skip to main content
15,898,222 members
Home / Discussions / C#
   

C#

 
GeneralRe: Circumstances in which you would use Tuple in your real-world code ? Pin
Not Active5-Dec-11 2:40
mentorNot Active5-Dec-11 2:40 
GeneralRe: Circumstances in which you would use Tuple in your real-world code ? Pin
#realJSOP5-Dec-11 2:48
professional#realJSOP5-Dec-11 2:48 
GeneralRe: Circumstances in which you would use Tuple in your real-world code ? Pin
Not Active5-Dec-11 3:04
mentorNot Active5-Dec-11 3:04 
GeneralRe: Circumstances in which you would use Tuple in your real-world code ? Pin
SledgeHammer015-Dec-11 10:00
SledgeHammer015-Dec-11 10:00 
AnswerRe: Circumstances in which you would use Tuple in your real-world code ? Pin
David Skelly5-Dec-11 3:32
David Skelly5-Dec-11 3:32 
GeneralRe: Circumstances in which you would use Tuple in your real-world code ? Pin
BillWoodruff5-Dec-11 6:27
professionalBillWoodruff5-Dec-11 6:27 
AnswerRe: Circumstances in which you would use Tuple in your real-world code ? Pin
Ennis Ray Lynch, Jr.5-Dec-11 8:06
Ennis Ray Lynch, Jr.5-Dec-11 8:06 
AnswerRe: Circumstances in which you would use Tuple in your real-world code ? Pin
BobJanova6-Dec-11 4:32
BobJanova6-Dec-11 4:32 
I would never use one in production code. They might be useful for a quick hack to produce a technical prototype, but they seem like a step backward to me, in that you lose all semantic meaning of the type declaration. (You don't return ArrayList from methods, do you? Think about why not, and how much of that also applies to a typed tuple.)

It's trivial to create a custom data storage class to hold a multi-part return and you can give that a meaningful name, provide helpful reading or manipulation methods and so on which relate directly to the particular use you want to put the class to.

I use tuples in prototyping or dynamic languages where they are syntactically convenient and the expectations of meaning and type safety are relaxed (e.g. APL) – but even there, most of those languages now support the dynamic creation of objects which you can use to provide meaningful names for elements of the data. E.g. JavaScript:

function x(args){
 return { thing: 'result'; type: 'awesome'; answer: 42 };
}


That seems much clearer to me than
return ['result', 'awesome', 42];

... and the same applies in C#. Add onto that the clumsy looking declaration for a tuple (Tuple<string, string, int> is as long as CleverMethodResult) and I see no reason to use them.
GeneralRe: Circumstances in which you would use Tuple in your real-world code ? Pin
BillWoodruff6-Dec-11 10:09
professionalBillWoodruff6-Dec-11 10:09 
QuestionPlease Help me Pin
Arunkumar.Koloth4-Dec-11 7:18
Arunkumar.Koloth4-Dec-11 7:18 
AnswerRe: Please Help me Pin
Pete O'Hanlon4-Dec-11 8:21
mvePete O'Hanlon4-Dec-11 8:21 
AnswerRe: Please Help me Pin
Eddy Vluggen4-Dec-11 8:57
professionalEddy Vluggen4-Dec-11 8:57 
GeneralRe: Please Help me Pin
Addy Tas4-Dec-11 11:15
Addy Tas4-Dec-11 11:15 
GeneralRe: Please Help me Pin
Eddy Vluggen4-Dec-11 11:29
professionalEddy Vluggen4-Dec-11 11:29 
AnswerRe: Please Help me Pin
BillWoodruff4-Dec-11 13:44
professionalBillWoodruff4-Dec-11 13:44 
GeneralRe: Please Help me Pin
Peter_in_27804-Dec-11 13:50
professionalPeter_in_27804-Dec-11 13:50 
GeneralRe: Please Help me Pin
Arunkumar.Koloth4-Dec-11 15:04
Arunkumar.Koloth4-Dec-11 15:04 
GeneralRe: Please Help me Pin
BillWoodruff4-Dec-11 15:33
professionalBillWoodruff4-Dec-11 15:33 
AnswerRe: Please Help me Pin
Abhinav S4-Dec-11 17:50
Abhinav S4-Dec-11 17:50 
GeneralRe: Please Help me Pin
Arunkumar.Koloth4-Dec-11 20:36
Arunkumar.Koloth4-Dec-11 20:36 
GeneralRe: Please Help me Pin
Pete O'Hanlon4-Dec-11 21:13
mvePete O'Hanlon4-Dec-11 21:13 
GeneralRe: Please Help me Pin
Wayne Gaylard4-Dec-11 21:17
professionalWayne Gaylard4-Dec-11 21:17 
GeneralRe: Please Help me Pin
Arunkumar.Koloth5-Dec-11 1:34
Arunkumar.Koloth5-Dec-11 1:34 
GeneralRe: Please Help me Pin
Wayne Gaylard5-Dec-11 1:43
professionalWayne Gaylard5-Dec-11 1:43 
QuestionDatabase Not Opening Pin
AmbiguousName4-Dec-11 2:55
AmbiguousName4-Dec-11 2:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.