What to Return with Async CRUD methods
Posted
by
RualStorge
on Programmers
See other posts from Programmers
or by RualStorge
Published on 2014-08-19T14:46:25Z
Indexed on
2014/08/20
16:34 UTC
Read the original article
Hit count: 326
While there is a similar question focused on Java, I've been in debates with utilizing Task objects. What's the best way to handle returns on CRUD methods (and similar)?
Common returns we've seen over the years are:
- Void (no return unless there is an exception)
- Boolean (True on Success, False on Failure, exception on unhandled failure)
- Int or GUID (Return the newly created objects Id, 0 or null on failure, exception on unhandled failure)
- The updated Object (exception on failure)
- Result Object (Object that houses the manipulated object's ID, Boolean or status field to with success or failure indicated, Exception information if there was one, etc)
The concern comes into play as we've started moving over to utilizing C# 5's Async functionality, and this brought the question up of how we should handle CRUD returns large-scale. In our systems we have a little of everything in regards to what we return, we want to make these returns standardized...
Now the question is what is the recommended standard? Is there even a recommended standard yet? (I realize we need to decide our standard, but typically we do so by looking at best practices, see if it makes sense for us and go from there, but here we're not finding much to work with)
© Programmers or respective owner