> 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.

The point is that unless you can _guarantee_ that parameters are immutable,
then a lot of damage and bad side effects can happen during a method call.

The simplest way of adding an extra layer of protection is to simply add
"final" to the method param. That way you know for sure at compile time
(i.e. more brainless stuff to take a load off all the already existing
complexity in the system) that you're not causing any side effects.


YMMV, but I've found that once you get used to "final", you don't even
notice it anymore. In fact quite the opposite: you notice more when it's
_not_ there (which I guess is the whole point of having it in the first
place).


Cheers,
Dave



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

Reply via email to