I believe that this is more of an inheritency question, but since I am trying to grasp it better by implementing a pattern that uses it, I thought I would ask my question related to get a better grasp.
If you use the Specification Pattern, having a number of specifications all deriving from Specification, and you wrap them with a wrapper specification class:
Example :
public class CustomerCreditCheck : Specification<Customer> {
private readonly UnlimitedCreditLimitSpecification unlimitedCreditLimitSpec = new UnlimitedCreditLimitSpecification();
private readonly SufficientCustomerCreditAmountSpec sufficientCustCreditAmtSpec = new SufficientCustomerCreditAmountSpec();
private readonly AcceptableCustomerCreditStatusSpecification acceptCustCreditStatusSpec = new AcceptableCustomerCreditStatusSpecification();
public override bool IsSatisfiedBy(Customer customer) {
return acceptCustCreditStatusSpec
.And(unlimitedCreditLimitSpec.Or(sufficientCustCreditAmtSpec))
.IsSatisfiedBy(customer);
}
}
My question is: since you are passing the customer Entity into the IsSatisfiedBy method of acceptCustCreditStatusSpec (first assumption), how does the customer entity get passed to the IsSatisifedBy method of both unlimitedCreditLimitSpec and SufficientCustCreditAmtSpec specifications?
Thanks,