good way to implement NotSpecification: isSpecialCaseOf?

Posted by koen on Stack Overflow See other posts from Stack Overflow or by koen
Published on 2010-04-07T18:51:45Z Indexed on 2010/04/09 20:53 UTC
Read the original article Hit count: 446

I'm implementing the specification pattern. The NotSpecification seems simple at first:

NotSpecification.IsSpecialCaseOf(otherSpecification)
    return !this.specification.isSpecialCaseOf(otherSpecification)

But it doesn't work for all Specifications:

Not(LesserThan(5)).IsSpecialCaseOf(GreaterThan(4))

This should be true. So far I think that the only way to accomplish the isSpecialCaseOf the NotSpecification is to implement the remainderUnsatisfiedBy (partial subsumption in the paper on the specification pattern). But maybe I am missing something more simple or a logical insight that makes this unnecessary.

Question: Is there another way of implementing this by not using remainderUnsatisfiedBy?

© Stack Overflow or respective owner

Related posts about specifications

Related posts about specification-pattern