Domain-Driven Design: Tackling Complexity in the Heart of Software



Download 7,21 Mb.
Pdf ko'rish
bet190/343
Sana17.11.2022
Hajmi7,21 Mb.
#867526
1   ...   186   187   188   189   190   191   192   193   ...   343
Bog'liq
Eric Evans 2003 - Domain-Driven Design - Tackling Complexity in the Heart of Software

Figure 10.15. The 
SPECIFICATION
 for a gasoline container has been
tightened.
In the language of 
SPECIFICATION
, we would say that the new 
SPECIFICATION
subsumes
the old
SPECIFICATION
, because any candidate that would satisfy the new SPEC would also satisfy the old.
If each of these 
SPECIFICATIONS
is viewed as a predicate, subsumption is equivalent to logical
implication. Using conventional notation, 
A
B
means that statement 
A
implies statement 
B
, so
that if 

is true, 
B
is also true.
Let's apply this logic to our container-matching needs. When a SPECIFICATION is being changed,
we would like to know if the proposed new SPEC meets all the conditions of the old one.
New Spec 
Old Spec
That is, if the new spec is true, then the old spec is also true. Proving a logical implication in a
general way is very difficult, but special cases can be easy. For example, particular parameterized
SPECS
can define their own subsumption rule.
public class MinimumAgeSpecification {
int threshold;
public boolean isSatisfiedBy(Person candidate) {
return candidate.getAge() >= threshold;
}
public boolean subsumes(MinimumAgeSpecification other) {
return threshold >= other.getThreshold();
}
}
A JUnit test might contain this:


drivingAge = new MinimumAgeSpecification(16);
votingAge = new MinimumAgeSpecification(18);
assertTrue(votingAge.subsumes(drivingAge));
Another practical special case, one suited to address the 
Container Specification
problem, is a
SPECIFICATION
interface combining subsumption with the single logical operator AND.
public interface Specification {
boolean isSatisfiedBy(Object candidate);
Specification and(Specification other);
boolean subsumes(Specification other);
}
Proving implication with only the AND operator is simple:
A
AND 
B
A
or, in a more complicated case:
A
AND 
B
AND C 
A
AND 
B
So if the 

Download 7,21 Mb.

Do'stlaringiz bilan baham:
1   ...   186   187   188   189   190   191   192   193   ...   343




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2025
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish