Design Patterns : Elements of Reusable Object-Oriented Software


Design Patterns: Elements of Reusable Object-Oriented Software



Download 4,06 Mb.
Pdf ko'rish
bet41/288
Sana07.04.2022
Hajmi4,06 Mb.
#535140
1   ...   37   38   39   40   41   42   43   44   ...   288
Bog'liq
GOF Design Patterns

Design Patterns: Elements of Reusable Object-Oriented Software 
49 
Recursive Composition 
A common way to represent hierarchically structured information isthrough a 
technique called 
recursive composition
, whichentails building increasingly 
complex elements out of simpler ones.Recursive composition gives us a way to 
compose a document out ofsimple graphical elements. As a first step, we can tile 
a set ofcharacters and graphics from left to right to form a line in thedocument. 
Then multiple lines can be arranged to form a column,multiple columns can form 
a page, and so on (seeFigure 2.2). 
Figure 2.2: Recursive composition of text and graphics 
We can represent this physical structure by devoting an object to eachimportant 
element. That includes not just the visible elements likethe characters and 
graphics but the invisible, structural elements aswell

the lines and the column. 
The result is the object structureshown in Figure 2.3. 


Design Patterns: Elements of Reusable Object-Oriented Software 
50 
Figure 2.3: Object structure for recursive composition oftext and graphics 
By using an object for each character and graphical element in thedocument, we 
promote flexibility at the finest levels of Lexi'sdesign. We can treat text and 
graphics uniformly with respect to howthey are drawn, formatted, and embedded 
within each other. We canextend Lexi to support new character sets without 
disturbing otherfunctionality. Lexi's object structure mimics the 
document'sphysical structure. 
This approach has two important implications. The first is obvious:The objects 
need corresponding classes. The second implication, whichmay be less obvious, 
is that these classes must have compatibleinterfaces, because we want to treat 
the objects uniformly. The way tomake interfaces compatible in a language like 
C++ is to relate theclasses through inheritance. 

Download 4,06 Mb.

Do'stlaringiz bilan baham:
1   ...   37   38   39   40   41   42   43   44   ...   288




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