I ran the VS 2008 code analysis tool against an object I created and received the following suggestion ...
Warning 147 CA1021 : Microsoft.Design : Consider a design that does not require that 'returnValue' be an out parameter.
I find "out" parameters rather useful and didn't realize that they were considered as a frowned upon design practice. I wanted to know if someone could shed some light on the reason that I received this Warning? If it is bad practice? why? and what would be good practice?
I appreciate any advice.
Every Code Analysis warning has associated documentation that you can access by highligting the warning and pressing F1. You can also right-click on the item to get help.
In any case, here's the documentation that explains that particular warning.
I would say that there are a few cases where out parameters are still a good choice - particularly when it comes to the TryParse coding idiom, because it's such a well-established way of doing things that most people are supposed to understand it
In general use, however, there are better, more object-oriented solutions to multiple return values.