> On Mar 7, 2019, at 4:52 PM, Kevin Bourrillion <kev...@google.com> wrote:
> 
> On Thu, Mar 7, 2019 at 12:47 PM Brian Goetz <brian.go...@oracle.com 
> <mailto:brian.go...@oracle.com>> wrote:
> 
> Normalization can happen on single arguments or multiple:
> 
>      record Person(String name) { 
>           public Person {
>                name = name.toUpperCase();
>           }
>      }
> 
> (Note that I’m mutating the parameter, which will then get written to the 
> field.)
> 
> I'm a bit relieved to hear this. The document seemed to imply that you would 
> assign to the field, then later the remaining fields that weren't DA would be 
> set from the remaining parameters. I think parameter reassignment is superior 
> because there are never two versions of the data in scope at the same time. 
> (I think the argument against parameter reassignment is mainly that it's 
> heresy.)

I see no heresy in assigning to a non-final variable.

On the other hand, I’m a great believer in adding `final` to my method 
parameters, at least when there might be any doubt.

Anyone who complains that “Duh, parameters should *always* be final, why isn’t 
that the default?” will find me replying “Duh, local variables should *almost 
always* be final, why isn’t that the default?”

:-)

—Guy

Reply via email to