Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Is it necessary to avoid reassigning values to function parameters?

807605Aug 9 2007 — edited Aug 10 2007
I am currently using PMD to check the code quality of my project and it shows numerous violations. Among them the one is saying me to "Reassigning values to parameters is a questionable practice. Use a temporary local variable instead.".
Is it really necessary to do that for good programming practice. How bad it is if we does not use local variables for function parameters ?

It shows such violation if i have a function like this:
public class Foo {
 private void foo(String bar) {
  bar = "something else";
 }
}
Can anyone please explain me the cons violating that rule?
In which cases violating the rule cause the negative impacts?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 7 2007
Added on Aug 9 2007
31 comments
1,628 views