Timeline for Is using "out" or "ref" parameters in Java methods to return extra values bad?
Current License: CC BY-SA 3.0
6 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Dec 22, 2013 at 17:27 | comment | added | carbontax | Plus one because the new return Type is going to be unit testable. And the method is future proof since changes to the structure of returned data are encapsulated by the Type | |
| Apr 4, 2013 at 20:57 | vote | accept | hyde | ||
| Mar 29, 2013 at 11:44 | comment | added | hyde | I think this is what I find clear yet simple about "out" parameters: they have a name, without requiring creation of a new type. And I think creation of extra type is clutter if it is only used as return type of single method, and does not have any custom behaviour (ie. methods other than setters and getters). | |
| Mar 29, 2013 at 5:59 | comment | added | jhewlett | I would rather create a class than try to figure out what 'tuple.Item1' represents. | |
| Mar 28, 2013 at 16:51 | comment | added | Robert Harvey |
C# has an idiom called TryParse. It relies on an out parameter to get the parsed value, and returns a boolean indicating success or failure. It's the only time I really use out; making a class just for a return value seems a bit pointless, unless you use it everywhere where you need a number and a success indicator. I suppose you could simply return a Tuple<T, bool>.
|
|
| Mar 28, 2013 at 16:43 | history | answered | parsifal | CC BY-SA 3.0 |