|
I agree that this is a valid aproach to avoid the issue, and I also couldn't agree more that it starts as a semantic issue.
The approach you describe can actually be enforced easily. You add a flag that this particular point in the object's lifecycle is reached and then throw an IllegalStateException on each call to relevant setters. The extra costs at runtime are reasonably low -- a new boolean member and some checks in methods that should not be called often; after all that is what the checks enforce.
I did not intend to say that the problem can not be fixed, it just requires attention. More could be said on this topic, but the space in an article is limited.
|