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


Figure 5.1. Some traversal directions reflect a natural bias in the



Download 7,21 Mb.
Pdf ko'rish
bet59/343
Sana17.11.2022
Hajmi7,21 Mb.
#867526
1   ...   55   56   57   58   59   60   61   62   ...   343
Bog'liq
Eric Evans 2003 - Domain-Driven Design - Tackling Complexity in the Heart of Software

Figure 5.1. Some traversal directions reflect a natural bias in the
domain.


Very often, deeper understanding leads to a "qualified" relationship. Looking deeper into
presidents, we realize that (except in a civil war, perhaps) a country has only one president at a
time. This qualifier reduces the multiplicity to one-to-one, and explicitly embeds an important rule
into the model. Who was president of the United States in 1790? George Washington.
Figure 5.2. Constrained associations communicate more knowledge
and are more practical designs.
Constraining the traversal direction of a many-to-many association effectively reduces its
implementation to one-to-many—a 
much 
easier design.
Consistently constraining associations in ways that reflect the bias of the domain not only makes
those associations more communicative and simpler to implement, it also gives significance to the
remaining bidirectional associations. When the bidirectionality of a relationship is a semantic
characteristic of the domain, when it's needed for application functionality, the retention of both
traversal directions conveys that.
Of course, the ultimate simplification is to eliminate an association altogether, if it is not essential
to the job at hand or the fundamental meaning of the model objects.
Example
Associations in a Brokerage Account


Figure 5.3.
One Java implementation of 
Brokerage Account
in this model would be
public class BrokerageAccount {
String accountNumber;
Customer customer;
Set investments;
// Constructors, etc. omitted
public Customer getCustomer() {
return customer;
}
public Set getInvestments() {
return investments;
}
}
But if we need to fetch the data from a relational database, another implementation, equally
consistent with the model, would be the following:

Download 7,21 Mb.

Do'stlaringiz bilan baham:
1   ...   55   56   57   58   59   60   61   62   ...   343




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
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