
Originally Posted by
cepage
There are a lot of smart people who get concerned about the mutators, and I'd love to have a better understanding why.
With good OO design, you should be accessing classes through their interfaces, and not through their concrete implementations, and Spring does a great job of helping you to implement your applications this way.
For injected dependencies, I don't put mutators in the public interface. Period. Yes, there is a public setter method, but if your code is accessing the bean through its interface, then for all practical purposes it is private.
Sure, Spring doesn't 'enforce' private access to the mutator, but the only way you could get to it is by directly invoking the class's concrete constructor (or casting to a concrete class), and that's a no-no.
If you can't get your team to reference classes through injected interfaces, rather than invoking concrete constructors, then you aren't going to be able to 'enforce' OO principles anyway, and Spring can't do anything about that.