Timeline for Is using "out" or "ref" parameters in Java methods to return extra values bad?
Current License: CC BY-SA 3.0
14 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Aug 11, 2014 at 17:38 | comment | added | bacar |
An alternative seems to be commons-lang's MutableObject<T>. If you're already using that library, this may convey your intent better than Holder<T> does (using something from javax.xml.ws may seem odd). Also comes with a bunch of non-boxing siblings like MutableDouble
|
|
| Dec 22, 2013 at 15:50 | comment | added | Donal Fellows |
FWIW, I wouldn't make a Mutable<T> when there's an existing Holder<T> available with your Java distribution. (It's used for modelling out parameters in JAX-WS; surprise surprise…)
|
|
| Dec 22, 2013 at 15:12 | answer | added | tia | timeline score: 1 | |
| Dec 21, 2013 at 22:33 | comment | added | hyde | @user949300 certainly possible, but how is that different from returning an array? | |
| Dec 21, 2013 at 20:13 | comment | added | user949300 | In this particular example I'd have the method return the Set, with null (or perhaps empty) meaning false. | |
| Dec 21, 2013 at 16:22 | answer | added | supercat | timeline score: 1 | |
| Apr 4, 2013 at 20:57 | vote | accept | hyde | ||
| Mar 28, 2013 at 16:49 | answer | added | Scott Whitlock | timeline score: 4 | |
| Mar 28, 2013 at 16:49 | comment | added | ratchet freak | ugh don't diss things just because they are "heavy", for most applications something "heavy" but easy to use is better than a "light" custom awkward construct, also no-one is forcing you to use the checked exception classes, when failure is a common result though a null return value is enough to signal an error | |
| Mar 28, 2013 at 16:43 | answer | added | parsifal | timeline score: 13 | |
| Mar 28, 2013 at 16:40 | history | edited | hyde | CC BY-SA 3.0 |
changed logging to imply debugging
|
| Mar 28, 2013 at 16:36 | comment | added | hyde |
@ratchetfreak Exceptions are fairly heavy, and do not fit every situation. A good sign of return value being better is, if most code would have empty catch block (which gets replaced by non-existent else when return value is used instead). Opposite of success is not always failure. Changed code to imply logging only as debug measure.
|
|
| Mar 28, 2013 at 16:31 | comment | added | ratchet freak | in your example returning null or rethrowing the Exception (wrapped or not) up the stack to handle it there instead of a boolean success return value (which have been deprecated since exceptions) | |
| Mar 28, 2013 at 16:25 | history | asked | hyde | CC BY-SA 3.0 |