is it better practice to return a complex object or use reference/out parameters?

Viewed 4482

I'm putting together a method which is supposed to evaluate the input and return true if all conditions are met or false if some test fails. I'd also like to have some sort of status message available to the caller if there's a failure.

Designs I've come across include returning the bool and using an out (or ref) parameter for the message, returning an instance of a (specifically designed) class with the bool and string properties, or even returning an enum indicating pass or a specific error. what's the best way to get all the information out of the method? Are any of these "good"? Does anyone have other recommendations?

14 Answers
Related