Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jgit-dev] Avoiding unnecessary use of "final"

On Tuesday, May 15, 2018 02:14:49 PM Jonathan Nieder wrote:
> If I don't hear anything in the next day, I'll assume
> that's because everyone is enthusiastic about this coding
> standards change and will update the wiki accordingly. :)

I like them, :)

-Martin

> пн, 14 мая 2018 г. в 14:59, Jonathan Nieder 
<jrn@xxxxxxxxxx>:
> > Hi,
> > 
> > Context: https://git.eclipse.org/r/c/122605/
> > 
> > 
> > https://gerrit-review.googlesource.com/Documentation/dev
> > -contributing.html#style> 
> >  contains:
> > When to use `final` modifier and when not (in new code):
> > 
> > Always:
> >   * final fields: marking fields as final forces them to
> >   be
> >   initialized in the constructor or at declaration
> >   * final static fields: clearly communicates the intent
> >   * to use final variables in inner anonymous classes
> > 
> > Optional:
> >   * final classes: use when appropriate, e.g. API
> >   restriction * final methods: similar to final classes
> > 
> > Never:
> >   * local variables: it clutters the code, and makes the
> >   code less readable. When copying old code to new
> >   location, finals should be removed
> >   * method parameters: similar to local variables
> > 
> > I'm enough used to this that I had assumed JGit uses the
> > same style, but now that I check
> > https://wiki.eclipse.org/EGit/Contributor_Guide#Coding_s
> > tandards I don't see it. I would like to propose we
> > adopt the same standards.
> > 
> > Objections? Are there tools that can update older parts
> > of the codebase that overuse 'final' (just like older
> > parts of Gerrit did)? Other thoughts?
> > 
> > Thanks,
> > Jonathan

-- 
The Qualcomm Innovation Center, Inc. is a member of Code 
Aurora Forum, hosted by The Linux Foundation



Back to the top