This is true and with enterprise applications it irritates me quite a lot.Quote:
Originally Posted by rebornspirit
Personally I would use the ServiceLocator to get my dependencies. Your design won`t be damaged as much as the anemic domain model (putting all the logic in service-like objects).Quote:
I agree that this is the best way, the problem is that Spring has no nice way to handle this and I cannot use the solution in the sandbox.Code:class Employee{
void setSalary(int amount){
Validator validator = ... retrieve salary validator
validator.validate(amount);
_amount = amount;
}
}
So I guess that you would move the validation to the service, corect?
