R
Roedy Green
Lets say you noticed that your constructor was getting overweight, and
decided to split it into more manageable chunks.
All of a sudden all your finals on the instance variable become
ERRORS!!!
The is correct because in THEORY someone later could call one of your
dependent methods.
So you remove your finals.
This is NOT a good thing.
It makes it look as though these are NOT final to other programmers.
You take off your safety wheels protecting you from duplicate
assignment or inadvertent assignment.
This usually happens when you are shuffling code around. You get some
dups.
I have two ideas to ameliorate the situation.
1. an @once annotation that says this static method can be run only
once, or this instance method can be invoked only once per object
instantiation. It would be backed by a weak transparent assert that
would be turned off when running in production. The compiler would
use the annotation to allow extra finals.
Such an annotation would be a great as general documentation and as
part of as assert mechanism.
2. IDEs should have a shuffle mode/refactor mode cut/paste. The idea
is you can move code around but not destroy or duplicate it.
You can create new code. This idea needs to be fleshed out. The
problem with any manual refactoring is you randomly lose a line of
code somewhere or duplicate one.
--
Roedy Green Canadian Mind Products
http://mindprod.com
"Species evolve exactly as if they were adapting as best they could to a changing world, and not at all as if they were moving toward a set goal."
~ George Gaylord Simpson
decided to split it into more manageable chunks.
All of a sudden all your finals on the instance variable become
ERRORS!!!
The is correct because in THEORY someone later could call one of your
dependent methods.
So you remove your finals.
This is NOT a good thing.
It makes it look as though these are NOT final to other programmers.
You take off your safety wheels protecting you from duplicate
assignment or inadvertent assignment.
This usually happens when you are shuffling code around. You get some
dups.
I have two ideas to ameliorate the situation.
1. an @once annotation that says this static method can be run only
once, or this instance method can be invoked only once per object
instantiation. It would be backed by a weak transparent assert that
would be turned off when running in production. The compiler would
use the annotation to allow extra finals.
Such an annotation would be a great as general documentation and as
part of as assert mechanism.
2. IDEs should have a shuffle mode/refactor mode cut/paste. The idea
is you can move code around but not destroy or duplicate it.
You can create new code. This idea needs to be fleshed out. The
problem with any manual refactoring is you randomly lose a line of
code somewhere or duplicate one.
--
Roedy Green Canadian Mind Products
http://mindprod.com
"Species evolve exactly as if they were adapting as best they could to a changing world, and not at all as if they were moving toward a set goal."
~ George Gaylord Simpson