Suppose I had the following method in an object:
public class foo
{
public bool DoSomethingAwesome()
{
bool bar = DidSomething() //suppose this sends an email;
return bar;
}
}
If I wanted to provide more detail on why DidSomething returned a false would the best practice be to assign a message to a Property to foo, or assign an Out parameter to DoSomethingAwesome?
I think this depends highly on the framework you’re using (i.e. it’s a convention).
GetLastError.
throwing an Exception but that could be
changed to match your circumstances.
Probably an out param would be ok.
If you decide to go with the Exception route, MSDN has an entry with “Design Guidelines for Exceptions“. And there’s a great discussion in the book “Framework Design Guidlines” – chapter 7, which I highly recommend!