I am reading Spring documentation and I am wondering what they meant by writing:
The Spring team generally advocates constructor injection as it enables one to implement application components as immutable objects and to ensure that required dependencies are not null.
I don't see in what way does it enable to implement components as immutable. Though I understand that using constructor-based DI is similar to a natural, Java way of creating objects of a class with final fields thus preventing object from changing fields references.
Was it the only reason they used such a phrase? Could someone explain that to me?
Thank you.
Aucun commentaire:
Enregistrer un commentaire