I'm trying to learn somethings about Dependency Injection and Specification Pattern.
If I have this scenario: I have three methods and they have different validation rules. This rules are validated by Specifications. So... My class must receive on the constructor these Specifications like this?
public PostService(IRepositorio rep, ISpecificationSave ss, SpecificationGet g, ISpecificationDelete sd) {
// do things...
}
But if is this correct, when I add a new method, I need to change de constructor to receive more one Specification?
Or, even using Dependency Inject, is better, in this case, create an instance of Specification on method how's use the Specification like that:
public void DoSomeThing(MyObject object) {
Specification<MyObject> specification = new Specification<MyObject>();
// do things...
}
I know the question is simple for some one of you, but I'm trying to learn those kinds of patterns yet.
Aucun commentaire:
Enregistrer un commentaire