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



Download 7,21 Mb.
Pdf ko'rish
bet213/343
Sana17.11.2022
Hajmi7,21 Mb.
#867526
1   ...   209   210   211   212   213   214   215   216   ...   343
Bog'liq
Eric Evans 2003 - Domain-Driven Design - Tackling Complexity in the Heart of Software

Example
Route-Finding Policies

Route Specification
is being passed to a 
Routing Service
, whose job is to construct a
detailed 
Itinerary
that satisfies the 
SPECIFICATION
. This 
SERVICE
is an optimization engine that can
be tuned to find either the fastest route or the cheapest one.
Figure 12.1. A 
SERVICE
 interface with options will need conditional logic.
This setup looks OK, but a detailed look at the routing code would reveal conditionals in every
computation, making the decision between fastest or cheapest appear all over the place. More
trouble will come when new criteria are added to make more subtle choices between routes.
One approach is to separate those tuning parameters into 
STRATEGIES
. Then they can be
represented explicitly, passed into the 
Routing Service
as a parameter.
The 
Routing Service
now handles all requests in the same, unconditional way, looking for a
sequence of 
Legs
with a low magnitude, as computed by the 
Leg Magnitude Policy
.
This design has the advantages that motivate the 
STRATEGY
pattern in 
Design Patterns
. On the
level of application versatility and flexibility, the behavior of the 
Routing Service
can now be
controlled and extended by installing an appropriate 
Leg Magnitude Policy
. The 
STRATEGIES
illustrated in Figure 12.2 (fastest or cheapest) are only the most obvious ones. Combinations that
balance speed and cost are likely. There may be other factors altogether, such as a bias toward
booking cargo on the company's own transports rather than subcontracting to carry them on the
transports of other shipping companies. These modifications could have been made without
resorting to 
STRATEGIES
, but the logic would have wound through the internals of the 

Download 7,21 Mb.

Do'stlaringiz bilan baham:
1   ...   209   210   211   212   213   214   215   216   ...   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