Clean Architecture



Download 6,37 Mb.
Pdf ko'rish
bet145/259
Sana26.02.2022
Hajmi6,37 Mb.
#465587
1   ...   141   142   143   144   145   146   147   148   ...   259
Bog'liq
Clean Architecture A Craftsman’s Guide to Software Structure and Design by Robert C. Martin (z-lib.org)

231
26
Th e M a in 
C o m pon e nt
www.EBooksWorld.ir


Chapter 26 The Main Component
232
In every system, there is at least one component that creates, coordinates, and 
oversees the others. I call this component 
Main
.
Th e U lti m at e D e ta i l
The 
Main
component is the ultimate detail—the lowest-level policy. It is the initial 
entry point of the system. Nothing, other than the operating system, depends on 
it. Its job is to create all the Factories, Strategies, and other global facilities, and 
then hand control over to the high-level abstract portions of the system. 
It is in this 
Main
component that dependencies should be injected by a 
Dependency Injection framework. Once they are injected into 
Main

Main
should distribute those dependencies normally, without using the framework. 
Think of 
Main
as the dirtiest of all the dirty components. 
Consider the following 
Main
component from a recent version of Hunt the 
Wumpus. Notice how it loads up all the strings that we don’t want the main 
body of the code to know about.
public class Main implements HtwMessageReceiver {
private static HuntTheWumpus game;
private static int hitPoints = 10;
private static final List caverns = new 
ArrayList<>();
private static final String[] environments = new String[]{
"bright",
"humid",
"dry",
"creepy",
"ugly",
"foggy",
"hot",
www.EBooksWorld.ir


The Ultimate Detail
233
"cold",
"drafty",
"dreadful"
};
private static final String[] shapes = new String[] {
"round",
"square",
"oval",
"irregular",
"long",
"craggy",
"rough",
"tall",
"narrow"
};
private static final String[] cavernTypes = new String[] {
"cavern",
"room",
"chamber",
"catacomb",
"crevasse",
"cell",
"tunnel",
"passageway",
"hall",
"expanse"
};
private static final String[] adornments = new String[] {
www.EBooksWorld.ir



Download 6,37 Mb.

Do'stlaringiz bilan baham:
1   ...   141   142   143   144   145   146   147   148   ...   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