3 ms·
A method shouldn't know whether its consumer can do something meaningful on failure. Return an error value and let them decide.
by zmj 9y ago
A method shouldn't know whether its consumer can do something meaningful on failure. Return an error value and let them decide.
- danbruc 9y agoYou are not writing a function in a vacuum. You make choices about how arguments are passed into the function and choices about how results are returned from the function including errors. Optional values and exceptions offer different trade-offs and you should pick the one that is probably most useful and most easy to work with. What do I know what the caller will do with my return value, I will just return a XML string with the serialized result and let them do with that whatever they want is probably not a good design philosophy to adopt either.