I disagree and hold that parameters are nothing more than local variables initialized by the syntax of calling the method
I adopt a third position: parameters are just like local variables: both should be treated as immutable by default. So variables are assigned once and then only read from, not altered. In the case of loops, for each (x in ...), the variable is immutable within the context of each iteration. The reasons for this are:
- it makes the code easier to "execute in my head",
- it allows more descriptive names for the variables.
Faced with a method with a bunch of variables that are assigned and then do not change, I can focus on reading the code, rather than trying to remember the current value of each of those variables.
Faced with that same method, this time with less variables, but that change value all the time, I now have to remember the current state of those variables, as well as working at what the code is doing.
In my experience, the former is far easier on my poor brain. Other, cleverer, folk than me may not have this problem, but it helps me.
As for the other point:
double Foo(double r)
{
r = r * r;
r = Math.Pi * r;
return r;
}
versus
double Foo(int r)
{
var rSquared = r * r;
var area = Math.Pi * rSquared;
return area;
}
Contrived examples, but to my mind it's much clearer as to what's going on in the second example due to the variable names: they convey far more information to the reader than that mass of r's do in the first example.