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



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

Associations
The interaction between modeling and implementation is particularly tricky with the associations
between objects.
For every traversable association in the model, there is a mechanism in the software with the
same properties.
A model that shows an association between a customer and a sales representative corresponds to
two things. On one hand, it abstracts a relationship developers deemed relevant between two real
people. On the other hand, it corresponds to an object pointer between two Java objects, or an
encapsulation of a database lookup, or some comparable implementation.
For example, a one-to-many association might be implemented as a collection in an instance
variable. But the design is not necessarily so direct. There may be no collection; an accessor
method may query a database to find the appropriate records and instantiate objects based on
them. Both of these designs would reflect the same model. The design has to specify a particular
traversal mechanism whose behavior is consistent with the association in the model.
In real life, there are lots of many-to-many associations, and a great number are naturally
bidirectional. The same tends to be true of early forms of a model as we brainstorm and explore
the domain. But these general associations complicate implementation and maintenance.
Furthermore, they communicate very little about the nature of the relationship.
There are at least three ways of making associations more tractable.
Imposing a traversal direction
1.
Adding a qualifier, effectively reducing multiplicity
2.
Eliminating nonessential associations
3.
It is important to constrain relationships as much as possible. A bidirectional association means
that both objects can be understood only together. When application requirements do not call for
traversal in both directions, adding a traversal direction reduces interdependence and simplifies
the design. Understanding the domain may reveal a natural directional bias.
The United States has had many presidents, as have many other countries. This is a bidirectional,
one-to-many relationship. Yet we seldom would start out with the name "George Washington" and
ask, "Of which country was he president?" Pragmatically, we can reduce the relationship to a
unidirectional association, traversable from country to president. This refinement actually reflects
insight into the domain, as well as making a more practical design. It captures the understanding
that one direction of the association is much more meaningful and important than the other. It
keeps the "Person" class independent of the far less fundamental concept of "President."

Download 7,21 Mb.

Do'stlaringiz bilan baham:
1   ...   54   55   56   57   58   59   60   61   ...   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