ONJava.com -- The Independent Source for Enterprise Java
oreilly.comSafari Books Online.Conferences.

advertisement

AddThis Social Bookmark Button
Article:
  Seven Low-Cost Ways to Improve Legacy Code
Subject:   Heuristics vs Rules
Date:   2004-06-09 14:57:57
From:   Kevin O'Neill
One issue I have when presenting these sort of things to junior developers (or even seniors who have lost their way :)) is to make them understand that these this represent "rules of thumb" as apposed to "rules of law".


I'm interested in the following statement.


Every parameter to a method should be declared final unless the parameter is intended to be an out or in-out parameter.


Now am I a big user of final but I don't understand how it effects out or in-out parameters. Even if the instance reference is declared final it's contents can be modifed. In fact for out or in-out parameters (ie parameters whose internal structure you are going to modify) you should always declare them as final to ensure that method code does not change the refered to instance. Or is there something that I'm missing?



1 to 1 of 1
1 to 1 of 1