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



Download 7,21 Mb.
Pdf ko'rish
bet160/343
Sana17.11.2022
Hajmi7,21 Mb.
#867526
1   ...   156   157   158   159   160   161   162   163   ...   343
Bog'liq
Eric Evans 2003 - Domain-Driven Design - Tackling Complexity in the Heart of Software

Invoices
and then have to
select from them in memory. Whether this is an acceptable cost for the better factoring of
responsibility depends entirely on circumstances. There are many ways to implement the
interactions between 
SPECIFICATIONS
and 
REPOSITORIES
, to take advantage of the development
platform, while keeping the basic responsibilities in place.
Sometimes, to improve performance, or more likely to tighten security, queries may be
implemented on the server as stored procedures. In that case, the 
SPECIFICATION
could carry only
the parameters allowed by the stored procedure. For all that, there is no difference in the model
between these various implementations. The choice of implementation is free except where
specifically constrained by the model. The price comes in a more cumbersome way of writing and
maintaining queries.
This discussion barely scratches the surface of the challenges of combining 
SPECIFICATIONS
with
databases, and I'll make no attempt to cover all the considerations that may arise. I just want to
give a taste of the kind of choices that have to be made. Mee and Hieatt discuss a few of the
technical issues involved in designing 
REPOSITORIES
with 
SPECIFICATIONS
in Fowler 2002.
Building to Order (Generating)
When the Pentagon wants a new fighter jet, officials write a specification. This specification may
require that the jet reach Mach 2, that it have a range of 1800 miles, that it cost no more than
$50 million, and so on. But however detailed it is, the specification is not a design for a plane,
much less a plane. An aerospace engineering company will take the specification and create one or
more designs based on it. Competing companies may produce different designs, all of which
presumably satisfy the original spec.
Many computer programs generate things, and those things have to be specified. When you place
a picture into a word-processing document, the text flows around it. You have specified the
location of the picture, and perhaps the style of text flow. The exact placement of the words on the
page is then worked out by the word processor in such a way that it meets your specification.


Although it may not be apparent at first, this is the same concept of a 
SPECIFICATION
that was
applied to validation and selection. We are specifying criteria for objects that are not yet present.
The implementation will be quite different, however. This 
SPECIFICATION
is not a filter for
preexisting objects, as with querying. It is not a test for an existing object, as with validation. This
time, a whole new object or set of objects will be made or reconfigured to satisfy the
SPECIFICATION
.
Without using 
SPECIFICATION
, a generator can be written that has procedures or a set of
instructions that create the needed objects. This code implicitly defines the behavior of the
generator.
Instead, an interface of the generator that is defined in terms of a descriptive 
SPECIFICATION
explicitly constrains the generator's products. This approach has several advantages.
The generator's implementation is decoupled from its interface. The 
SPECIFICATION
declares
the requirements for the output but does not define how that result is reached.
The interface communicates its rules explicitly, so developers can know what to expect from
the generator without understanding all details of its operation. The only way to predict the
behavior of a procedurally defined generator is to run cases or to understand every line of
code.
The interface is more flexible, or can be enhanced with more flexibility, because the
statement of the request is in the hands of the client, while the generator is only obligated to
fulfill the letter of the 
SPECIFICATION
.
Last, but not least, this kind of interface is easier to test, because the model contains an
explicit way to define input into the generator 
that is also a validation of the output
. That is,
the same 
SPECIFICATION
that is passed into the generator's interface to constrain the creation
process can also be used, in its validation role (if the implementation supports it) to confirm
that the created object is correct. (This is an example of an 
ASSERTION
, discussed in Chapter
10.)
Building to order
can mean creation of an object from scratch, but it can also be a configuration of
preexisting objects to satisfy the 
SPEC
.

Download 7,21 Mb.

Do'stlaringiz bilan baham:
1   ...   156   157   158   159   160   161   162   163   ...   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