Cette page n'est pas encore disponible en français, sa traduction est en cours. Si vous avez des questions ou des retours sur notre projet de traduction actuel, n'hésitez pas à nous contacter.
Avoid reassigning values to method parameters as it can make the code harder to understand. Typically, parameter values are expected to remain unchanged throughout the method’s execution, and any reassignment might be not be noticed by other developers.
We consider it acceptable to reassign parameters in small functions, smaller than 20 lines. Otherwise, consider using temporary local variables with clear naming to enhance code readability.
Non-Compliant Code Examples
publicclassPerson{privatevoidgreet(Stringname){System.println("this is a long method");System.println("this is a very long method");name=name.trim();// reassigning parameter valueSystem.println("this is a long method");System.println("this is a long method");System.println("this is a long method");System.println("this is a long method");System.println("this is a long method");System.println("this is a long method");System.println("this is a long method");System.println("this is a long method");System.println("this is a long method");System.println("this is a long method");System.println("this is a long method");System.println("this is a long method");System.println("this is a long method");System.println("this is a long method");System.println("this is a long method");System.println("this is a long method");System.println("this is a long method");System.println("this is a long method");System.println("this is a long method");System.println("this is a long method");System.println("this is a long method");System.println("this is a long method");System.println("this is a long method");System.println("this is a long method");System.println("this is a long method");System.println("this is a long method");System.println("this is a long method");System.println("this is a long method");}}