I would like to be able to indicate that the member variables of an object are immutable after the object has been “initialized”, which for me means that after it has been added with any dependencies, and performed any other initialization operations that it can perform only after DI.
Are there languages that satisfy my interest - formalize DI, initialization, and maintain immutability in this way? Maybe it's stupid to make them part of the language; probably no. I'm not sure.
Today I program in Java, but I can’t use "final" almost as much as I want, because these phases occur after the constructor has completed execution. Any tips on how to get what I want using Java? I assume that my objects can implement the base class so that these phases happen before the constructor finishes, or use aspects to do the same.
Thoughts?
source
share