I have a different point of view.
Despite the small problems associated with changing the value of parameters that may arise during debugging or reading code, it makes no sense for me to call this practice an “anti-pattern”.
Based on modern projects of OO languages such as Java or C #, I support the idea that if it is ugly, incorrect, or it is not recommended to change the parameter values, they would make certain parameters of the type as copies of the instances, and not the links.
And disagreeing with what Oded said, I think the ref or out keyword should only be used in contexts where you really want to change the value of the entire instance, completely replacing it. To use one of these keywords, just to say “hey guy, parameter values can change during stack execution” sounds a little careless to me. What if one of your customers sees the signature of the function and really believes that it can replace the whole thing? (in a situation that is not expected).
João Paulo Navarro
source share