c# - Refactoring code in using specification pattern for business rules -
I Specification
pattern to implement business rules in N-Layerd DDD I used to use the application I also used the CQRS
pattern in my application layer
. So I have defined the following in the interface
my domain
:
public interface ISPPfication & lt; T & gt; {Expression & lt; Funk & lt; T, bool & gt; & Gt; Preddict {Received; } Boolean Assurified By (T Entity); }
Anything else specificity
which is the big order explanation: ISPsification
. Special Order Explanation: ISpecification & lt; Order & gt;
.
I have used the following handler to process my orders:
Public class commanding process: CommandMandHandler
I think that violates the law of
, method
, violates
-
Do not ask for the theory, because it Satisfaction result from
br
asksorder
and then decides to do somethings. -
Open / Closed Principle, because if I want to add another specification, I have to change my
command handler
.How can I repeat my code to prevent this violation?
I would not say that it violates principles.
-
Principle / Strong>
Your code follows this principle because you define
handles
and your "logic" and "data" are kept in the same method.This can be violated if your
does some work
argument tells something tospecial order clarity
. -
Open / Closed Principle
Your code adheres to this principle because you have
ICommandHandler & lt; T & gt;
The interface should not be changed if you want to add another specificationIf you add one more specification then it can be violated
ICommandHandler & lt; T & gt;
Change the interface is necessary.
Follow the Dependency Inversion Principle . I suggest you use all your specifications (like BigOrderSpecification
, SpecialOrderSpecification
) Inject through the constructor.
Comments
Post a Comment