Clean Architecture


Chapter 14 Component Coupling



Download 6,37 Mb.
Pdf ko'rish
bet80/259
Sana26.02.2022
Hajmi6,37 Mb.
#465587
1   ...   76   77   78   79   80   81   82   83   ...   259
Bog'liq
Clean Architecture A Craftsman’s Guide to Software Structure and Design by Robert C. Martin (z-lib.org)

Chapter 14 Component Coupling
124
Figure 14.8 
An ideal configuration for a system with three components
The diagram in Figure 14.9 shows how the SDP can be violated.
Figure 14.9 
SDP violation
Flexible
is a component that we have designed to be easy to change. We 
want 
Flexible
to be unstable. However, some developer, working in the 
component named 
Stable
, has hung a dependency on 
Flexible
. This 
violates the SDP because the 

metric for 
Stable
is much smaller than the 

metric for 
Flexible
. As a result, 
Flexible
will no longer be easy to 
change. A change to 
Flexible
will force us to deal with 
Stable
and all its 
dependents.
To fix this problem, we somehow have to break the dependence of 
Stable
on 
Flexible
. Why does this dependency exist? Let’s assume that there is a 
www.EBooksWorld.ir


The Stable Dependencies Principle
125
class 
C
within 
Flexible
that another class 
U
within 
Stable
needs to use 
(Figure 14.10).
Figure 14.10 
U
within 
Stable
uses 
C
within 
Flexible
We can fix this by employing the DIP. We create an interface class called 
US
and put it in a component named 
UServer
. We make sure that this interface 
declares all the methods that 
U
needs to use. We then make 
C
implement this 
interface as shown in Figure 14.11. This breaks the dependency of 
Stable
on 
Flexible
, and forces both components to depend on 
UServer

UServer
is 
very stable (
I
=
0), and 
Flexible
retains its necessary instability (
I
=
1). All 
the dependencies now flow in the direction of 
decreasing I
.

Download 6,37 Mb.

Do'stlaringiz bilan baham:
1   ...   76   77   78   79   80   81   82   83   ...   259




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