I;m using final on both params and method local variables. It does not
help on writing the methods in the first place but on a later
"reading" of the method it helps by guaranteeing that the variable is
only assigned in that spot any not in any other spot within the method
so improving maintainability, debugging. If the "final" is there it
says that the variable is only assigned in that spot. If is not it
means that is could be assigned in some other place.
Is not our case, but I have seen people thinking that assigning a
value to the param, the value will be reflected back to the caller.
Having the final on the params would result in a compile error.

The point is that by having the final it will only help maintaining
the code a little but I do not think that we must have it as a
mandatory rule.

Alin

On Sun, May 25, 2008 at 3:38 AM, Niclas Hedhman <[EMAIL PROTECTED]> wrote:
> I must say that I have never understood the "final" on method
> arguments. It doesn't bring any value. If the method argument is a
> native type, I can change it as much as I want as it doesn't modify
> the caller's value. If the argument is a mutable object, "final"
> doesn't stop me from modifying the object, only the reference which in
> turn doesn't affect the caller. Similar for local variables. And IMHO,
> "final" adds a lot of clutter everywhere. I like using "final" where
> it makes a difference, not out of principle. -- Cheers, Niclas.
>
> On 5/24/08, Michael Hunger <[EMAIL PROTECTED]> wrote:
>> IntelliJ - switch on intentin "local variable can be final", go to any
>> highlight of this occurrence. Alt-Return -> Popup-Menu to the right -
>> use "Fix All" for current file or Run On ... to run it on the whole
>> module or even project. By now I had never an issue with these IDEA
>> finalized stuff (no false positives). So go ahead :)
>>
>> If the intention is switched on, your files all get quite yellow. Thats
>> easy to keep your eyes on.
>>
>> Michael
>>
>> Rickard Öberg schrieb:
>>> David Leangen wrote:
>>>> Hey,
>>>>
>>>> Just going through the code again a bit today. I noticed that there isn't
>>>> much use of "final" for classes, methods, or fields.
>>>>
>>>> What's the policy on that?
>>>
>>> In general, final is good. I'm just sloppy in applying it most of the
>>> time. My forte is not details, but rather the "big picture" :-) I would
>>> really appreciate havingh more eyes on the code to fix things like that.
>>>
>>> /Rickard
>>>
>>> _______________________________________________
>>> qi4j-dev mailing list
>>> [email protected]
>>> http://lists.ops4j.org/mailman/listinfo/qi4j-dev
>>
>>
>> _______________________________________________
>> qi4j-dev mailing list
>> [email protected]
>> http://lists.ops4j.org/mailman/listinfo/qi4j-dev
>>
>
> --
> Sent from Gmail for mobile | mobile.google.com
>
> _______________________________________________
> qi4j-dev mailing list
> [email protected]
> http://lists.ops4j.org/mailman/listinfo/qi4j-dev
>



-- 
Alin Dreghiciu
http://www.ops4j.org - New Energy for OSS Communities - Open
Participation Software.
http://www.qi4j.org - New Energy for Java - Domain Driven Development.
http://malaysia.jayway.net - New Energy for Projects - Great People
working on Great Projects at Great Places

_______________________________________________
qi4j-dev mailing list
[email protected]
http://lists.ops4j.org/mailman/listinfo/qi4j-dev

Reply via email to