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


Paint  class to make the test pass. Figure 10.3



Download 7,21 Mb.
Pdf ko'rish
bet169/343
Sana17.11.2022
Hajmi7,21 Mb.
#867526
1   ...   165   166   167   168   169   170   171   172   ...   343
Bog'liq
Eric Evans 2003 - Domain-Driven Design - Tackling Complexity in the Heart of Software

Paint 
class to make the test pass.
Figure 10.3.
The new method name may not tell the reader everything about the effect of "mixing in" another
Paint
(for that we'll need 
ASSERTIONS
, coming up in a few pages). But it will clue the reader in
enough to get started using the class, especially with the example the test provides. And it will
allow the reader of the client code to interpret the client's intent. In the next few examples in this
chapter, we'll refactor this class again to make it even clearer.


Entire subdomains can be carved off into separate modules and encapsulated behind 
INTENTION-
REVEALING INTERFACES
. Using such whittling to focus a project and manage the complexity of a
large system will be discussed more in Chapter 15, "Distillation," with 
COHESIVE MECHANISMS
and
GENERIC SUBDOMAINS
.
But in the next two patterns, we'll set out to make the consequences of using a method very
predictable. Complex logic can be done safely in 
SIDE-EFFECT-FREE FUNCTIONS
. Methods that change
system state can be characterized with 
ASSERTIONS
.
[ Team LiB ]


[ Team LiB ]
Side -Effect-Free Functions
Operations can be broadly divided into two categories, commands and queries. Queries obtain
information from the system, possibly by simply accessing data in a variable, possibly performing
a calculation based on that data. Commands (also known as modifiers) are operations that affect
some change to the systems (for a simple example, by setting a variable). In standard English, the
term 
side effect
implies an unintended consequence, but in computer science, it means any effect
on the state of the system. For our purposes, let's narrow that meaning to any change in the state
of the system that will affect future operations.
Why was the term 
side effect
adopted and applied to quite intentional changes affected by
operations? I assume this was based on experience with complex systems. Most operations call on
other operations, and those called invoke still other operations. As soon as this arbitrarily deep
nesting is involved, it becomes very hard to anticipate all the consequences of invoking an
operation. The developer of the client may not have intended the effects of the second-tier and
third-tier operations—they've become side effects in every sense of the phrase. Elements of a
complex design interact in other ways that are likely to produce the same unpredictability. The use
of the term 
side effect
underlines the inevitability of that interaction.

Download 7,21 Mb.

Do'stlaringiz bilan baham:
1   ...   165   166   167   168   169   170   171   172   ...   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