문제

I am trying to implement the composite specification pattern, as per the Specifications Document by Fowler and Evans.

At first impression, I thought the implementation of isGeneralizationOf would be different for conjunction and disjunction.

In particular, I thought the logic for conjunction would be

(1) Let specX be the conjunction of specA and specB. Then, specX is a generalization of specC only if both specA and specB are a generalization of specC.

And I thought the logic for disjunction would be

(2) Let specY be the disjunction of specA and specB. Then, specY is a generalization of specC if either specA or specB is a generalization of specC.

However, on page 16 of the document , they show this method:

CompositeSpecification >> isGeneralizationOf: aSpecification
"True if each component is subsumed. False if any component is not subsumed."
^ (self components contains:
        [:each |(each isGeneralizationOf: aSpecification) not ]) not

Is my reasoning in (1) and (2) correct? If it's wrong, why is that? If it's correct, then why did the authors define a single method to be inherited by both conjunction and disjunction specifications? What is their intent here?

올바른 솔루션이 없습니다

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top