Created
December 19, 2014 14:27
-
-
Save reidev275/03172e646b0771177d98 to your computer and use it in GitHub Desktop.
Descriptive responses from methods. Rather than returning null return an Atom or a Result<T>
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public enum Atom | |
{ | |
OK, Unauthorized, NotFound, Forbidden | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Result<T> | |
{ | |
readonly Atom _atom; | |
readonly T _obj; | |
public Result(Atom atom, T obj) | |
{ | |
_atom = atom; | |
_obj = obj; | |
} | |
public Atom Atom { get { return _atom; } } | |
public T Data { get { return _obj; } } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment