Dependency Injection and Specification Pattern

1

Good evening.

Can anyone help me understand this issue of the Specification Pattern and Dependency Injection?

For example:

In my service layer, I need to check if the user has filled in some information and if this information is within the expected conditions of the system (eg in a blog, the user fill in the title and the title has between three and sixty characters? ).

It might very well do something in the method to check this rule, but there could be several rules and would be a long and ugly method for this. In addition to breaking the SOLID rules.

Ok, I can implement a Basic Patter Specification for this. But, the service object (eg Blogs.PostService) would have to receive as a parameter the Repository plus the Specifications, right?

But if I have a method to query, one to save, one to delete ... the service object will have to receive a Specification for each situation (since the rules are different for each situation)? That is, it would have to have a constructor like:

public PostService(IRepositorio rep, ISpecificationSave ss, SpecificationGet g, ISpecificationDelete sd) { 
      // do things... 
}

I hope the issue is not too abstract ... I want to understand how I can relate these two techniques without making a lot of mess ...

Thanks for the guidance right away.

    
asked by anonymous 12.07.2016 / 00:12

0 answers