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


Figure 9.8. A deeper model after refactoring



Download 7,21 Mb.
Pdf ko'rish
bet148/343
Sana17.11.2022
Hajmi7,21 Mb.
#867526
1   ...   144   145   146   147   148   149   150   151   ...   343
Bog'liq
Eric Evans 2003 - Domain-Driven Design - Tackling Complexity in the Heart of Software

Figure 9.8. A deeper model after refactoring
In the refactored application, the nightly batch script tells each 
Asset
to
calculateAccrualsThroughDate()
. The return value is a collection of 
Accruals
, each of whose


amounts it posts to the indicated ledger.
The new model has several advantages. The change
Enriches the 
UBIQUITOUS LANGUAGE
with the term "accrual"
1.
Decouples accrual from payment
2.
Moves domain knowledge (such as which ledger to post to) from the script and into the
domain layer
3.
Brings fees and interest together in a way that fits the business and eliminates duplication in
the code
4.
Provides a straightforward path for adding new variations of fees and interest as 
Accrual
Schedules
5.
This time, the developer had to dig for the new concepts she needed. She could see the
awkwardness of the interest calculations and made a committed effort to look for a deeper
answer.
She was lucky to have an intelligent and motivated partner in the banking expert. With a more
passive source of expertise, she would have made more false starts and depended more on other
developers as brainstorming partners. Progress would have been slower, but still possible.
Contemplate Contradictions
Different domain experts see things different ways based on their experience and needs. Even the
same person provides information that is logically inconsistent after careful analysis. Such pesky
contradictions, which we encounter all the time when digging into program requirements, can be
great clues to deeper models. Some are just variations in terminology or are based on
misunderstanding. But there is a residue where two factual statements by experts seem to
contradict.
The astronomer Galileo once posed a paradox. The evidence of the senses clearly indicates that
the Earth is stationary: people are not being blown off and falling behind. Yet Copernicus had
made a compelling argument that the Earth was moving around the sun quite rapidly. Reconciling
this might reveal something profound about how nature works.
Galileo devised a thought experiment. If a rider dropped a ball from a running horse, where would
it fall? Of course, the ball would move along with the horse until it hit the ground by the horse's
feet, just as if the horse were standing still. From this he deduced an early form of the idea of
inertial frames of reference, solving the paradox and leading to a much more useful model of the
physics of motion.
OK. Our contradictions are usually not so interesting, nor the implications so profound. Even so,
this same pattern of thought often helps pierce the superficial layers of a problem domain into a
deeper insight.
It is not practical to reconcile all contradictions, and it may not even be desirable. (Chapter 14
delves into how to decide and how to manage the result.) However, even when a contradiction is
left in place, contemplation of how two statements could both apply to the same external reality
can be revealing.


Read the Book
Don't overlook the obvious when seeking model concepts. In many fields, you can find books that
explain the fundamental concepts and conventional wisdom. You still have to work with your own
domain experts to distill the part relevant to your problem and to crunch it into something suited
to object-oriented software. But you may be able to start with a coherent, deeply considered view.

Download 7,21 Mb.

Do'stlaringiz bilan baham:
1   ...   144   145   146   147   148   149   150   151   ...   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