Re: Re: Why variables that we don't modify should be final?

Alberto Ivo <[email protected]> Tue, 25 May 2010 20:06:01 -0300
Newsgroups gmane.comp.programming.refactoring
Message-ID <[email protected]>
hmm.. I see.. thanks very much for the answers..

Ivo


On Tue, May 25, 2010 at 7:03 PM, jcsextro <[email protected]> wrote:

>
>
> The perf improvement isn't the most compelling reason to make these
> variables final. IMHO, the added safety that comes with making it final is
> more compelling. It is then clear to everyone that comes behind you to
> maintain this code that once this value is set that the value never changes.
>
> It is easy enough to remove the final keyword if you decide at a later date
> that you do indeed need to modify the value stored in the variable for
> feature driven or test driven reasons. However, you should never have a test
> driven reason to change it because your tests would have driven you to
> implement a non-final variable right out of the box. :-)
>
> --- In [email protected] <refactoring%40yahoogroups.com>,
> Alberto Ivo <albertoivo@...> wrote:
> >
> > Hello,
> >
> > I just passed PMD in my Java code.. and a lot of variables the PMD says
> that
> > should be final.. just because I do not modify.
> > I know that, like this, it's safer because I'm sure that it wil be not
> > modified ever...
> > But, besides that, is there another advantage? like performance or
> anything
> > else?
> >
> > Thanks in advance.
> > Ivo
> >
> >
> > [Non-text portions of this message have been removed]
> >
>
>  
>


[Non-text portions of this message have been removed]



------------------------------------

Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/refactoring/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/refactoring/join
    (Yahoo! ID required)

<*> To change settings via email:
    [email protected] 
    [email protected]

<*> To unsubscribe from this group, send an email to:
    [email protected]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/