Clean Architecture


23 Pr e s e nte r s a n d



Download 6,37 Mb.
Pdf ko'rish
bet134/259
Sana26.02.2022
Hajmi6,37 Mb.
#465587
1   ...   130   131   132   133   134   135   136   137   ...   259
Bog'liq
Clean Architecture A Craftsman’s Guide to Software Structure and Design by Robert C. Martin (z-lib.org)

211
23
Pr e s e nte r s a n d 
H u m ble O bj ect s
www.EBooksWorld.ir


Chapter 23 Presenters and Humble Objects
212
In Chapter 22, we introduced the notion of presenters. Presenters are a form 
of the 
Humble Object
pattern, which helps us identify and protect 
architectural boundaries. Actually, the Clean Architecture in the last chapter 
was full of 
Humble Object
implementations.
Th e H u m b l e O bj e c t Pat t e r n
The 
Humble Object
pattern
1
is a design pattern that was originally identified 
as a way to help unit testers to separate behaviors that are hard to test from 
behaviors that are easy to test. The idea is very simple: Split the behaviors 
into two modules or classes. One of those modules is humble; it contains all 
the hard-to-test behaviors stripped down to their barest essence. The other 
module contains all the testable behaviors that were stripped out of the 
humble object.
For example, GUIs are hard to unit test because it is very difficult to write 
tests that can see the screen and check that the appropriate elements are 
displayed there. However, most of the behavior of a GUI is, in fact, easy to 
test. Using the 
Humble Object
pattern, we can separate these two kinds of 
behaviors into two different classes called the Presenter and the View.
Pr e s e n t e r s a n d Vi e w s
The View is the humble object that is hard to test. The code in this object is 
kept as simple as possible. It moves data into the GUI but does not process 
that data. 
The Presenter is the testable object. Its job is to accept data from the 
application and format it for presentation so that the View can simply move it 
to the screen. For example, if the application wants a date displayed in a field, 
it will hand the Presenter a 
Date
object. The Presenter will then format that 
1. 
xUnit Patterns
, Meszaros, Addison-Wesley, 2007, p. 695.
www.EBooksWorld.ir



Download 6,37 Mb.

Do'stlaringiz bilan baham:
1   ...   130   131   132   133   134   135   136   137   ...   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