Most developers (certainly myself!) are lazy. We look to re-use code and write the briefest code we can.
Sometimes it backfires!
When writing a method, either in Java or LotusScript, we can often pass parameters around with little concern. I came across that some years ago with LotusScript when objects were being changed by a function when I didn’t intend that. That was when I learned that you could define a sub or function in two ways. So consider the following code:
Dim myStr as String
myStr = "Test"
Sub mySub(passedVal as String)
passedVal = "Test 2"
What gets printed is actually “Test 2”, because myStr is passed in by reference rather than by value. So you’re passing in the String object, not passing its value to the sub / function. passedVal is the same object as myStr, so when you change one, you change both. The alternative would have been to enter:
Sub mySub (passedVal byVal as String)
Then what gets printed is “Test”, because you’re copying the value into a new String object called passedVal.
In Java, you use the keyword “final” to ensure an object passed in as a parameter cannot be changed. So:
readValue(final ViewEntry ve, final Vector<Object> columnValues)
It’s best practice to do so, though there may be times when it is more convenient to allow a method to modify values. There is a way to automatically add final to your parameters, in the Java Editor save actions preference, as Per Henrik Lausten pointed out. But note that may change references you don’t want it to.
— Per Henrik Lausten (@perlausten) March 4, 2014