On Thursday 29 May 2008 07:45, Michael Hunger wrote: > I'd rather not reuse variables and parameters. Mostly I revert to a more > functional style and create small method calculating the value and > returning it to the main scope (idempotent query methods) (refactorings: > extract method, convert temp to query-method, convert expression to > named method).
Agree to this 100% > You're right when you say that if your methods are small then final is > not neccessary. But when looking at the code in most professional > projects and even the (existing) qi4j runtime long methods of more that > 10 lines are ubiquitous. So making all possible local variables and > parameters final is a first step during refactoring that helps scoping > the method and extracting methods which are either commands or queries. And you are applying the wrong medicine for each problem. Problem Description; Blocks are sometimes too long to get a quick overview. Solution; Break the block and method into smaller chunks. Problem Description; I mistakenly re-use the same variable name, and end up over-writing the wrong one. Solution; Don't separate the declaration from the assignment. Problem Description; Sometime blocks can't be made smaller, and I am incapable of keeping declarations and assignments together. Solution; Use final THERE. Problem Description; There are 150,000 local variables and method arguments cluttered with the "final" filler, making the code harder to read. Solution; Don't use "final" everywhere, only where it matters. I am still -1 to a generic "final" filler. I have asked for a real-world bug-case, where the code doesn't apply to the "Solutions" above, and a hard to trace bug could have been avoided. I am tired to argue hypothetical cases. That is like doing the Java Puzzle games; Code constructed to be hard/impossible to understand what will really happen. It is exactly that; Constructions, not common sense applied programming. Cheers -- Niclas Hedhman, Software Developer I live here; http://tinyurl.com/2qq9er I work here; http://tinyurl.com/2ymelc I relax here; http://tinyurl.com/2cgsug _______________________________________________ qi4j-dev mailing list [email protected] http://lists.ops4j.org/mailman/listinfo/qi4j-dev

