> On Jun 13, 2019, at 4:15 PM, Ryan McMahon <rmcma...@pivotal.io> wrote:
> 
> I agree with this sentiment, and have generally only been using final on
> class fields and method parameters where I want to guarantee immutability
> as of late.  However, I was at one time adding final to local variables,
> and I know that I have checked in code with final locals.  Should we
> actively be removing finals when we see it on locals?
> 
> One case where I still have been using final for locals is when the
> variable is effectively constant and I want to show that intent.  For
> instance:
> final String resourceId =
> "someStaticResourceIdThatReallyShouldntBeReassignedEver";
> 
> Is this a valid use case or should we view this as unnecessary verbosity as
> well?

My preference (fairly strong) is not to mark locals and parameters as final, 
but I won’t go so far as to say it’s invalid to do so.

I would like to know more about the intent, so …

If such a local variable were not marked final, what bad thing do you think 
might happen?

A more positive version of the same question: If you’re able to show that the 
variable is effectively constant, what good things does that do for you?

—
Dale Emery
dem...@pivotal.io

Reply via email to