2008/5/25 Niclas Hedhman <[EMAIL PROTECTED]>:

> The more I think about it, the more I am convinced that it is even bad
> to use it for local variables and method arguments, as it doesn't
> assist in cross-developer communications.
>
> And if you can't track a couple of variables in a 10 line method, then
> I think you need to pick another profession. ;o)
>
> For methods and classes --> I am all for final as much as possible.
> But that is to enforce strict obedience to inheritence, which
> otherwise easily creates incompatibility problems in the future.
>
> For members, I am Ok with final, as it is much harder to get an
> overview of all usages within a class, than a small method.
>

+1 for using final on classes and methods (where appropriate)
to nail down inheritance - I also like to use final on members to
ensure they're all initialized properly, especially when there are
several constructor methods - although as Joshua Bloch says
(http://tinyurl.com/5axlkw) be careful wrt. readObject / clone.

0 for using final on method arguments and local variables, as
it can lead to false assumptions about immutability - these days
I only really use final for arguments when I'm providing a static
builder method that uses a anonymous class, such as:

   public Foo newFoo(final Bar bar) {
      new Foo() {
         // use bar here, etc...
      }
   }

just my 2 sen...

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



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

Reply via email to