2008/5/26 Lennart Boklund <[EMAIL PROTECTED]>:

> I agree to that. I think local variable reuse/reassignment is a code
> smell. And I see it quite often, making code harder to read.


not all local variable re-use is bad, there are several
use-cases ( like accumulating / narrowing of results )
where it makes more sense to re-use the same local
variable instead of creating a new one

imho adding extra locals can actually make such code
harder to read, and puts more burden on developers
to come up with clear names for all these extra locals.

as a guideline using final is ok, but don't overuse it :)

Method arguments I rarely (ever?) see reassigned.


I have written some short utility methods that re-use and
return method arguments, and they are clear and concise.
Adding extra locals would be overkill, and unnecessary.

Default final would make
> sense on both local variables and method arguments just to avoid bad
> programming.
>

Bad programming can occur even with default final because
a final object is still mutable (only its reference is fixed) - so
let's stick to having this as a guideline, not an enforced rule.

I'd much prefer people read books like "Effective Java" than
have them follow a set of rules without understanding them.

  Cheers / Lennart
>
> On 5/25/08, Michael Hunger wrote:
> ...
> > I'd rather have this as the default in the language and explicitly mark
> > non final stuff but thats to late by now :).
> >
> _______________________________________________
> 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