Design Patterns : Elements of Reusable Object-Oriented Software


Design Patterns: Elements of Reusable Object-Oriented Software



Download 4,06 Mb.
Pdf ko'rish
bet195/288
Sana07.04.2022
Hajmi4,06 Mb.
#535140
1   ...   191   192   193   194   195   196   197   198   ...   288
Bog'liq
GOF Design Patterns

Design Patterns: Elements of Reusable Object-Oriented Software 
290 
current element to the nextelement, and IsDone tests whether we've advanced beyond 
the lastelement

that is, we're finished with the traversal. 
Separating the traversal mechanism from the List object lets us defineiterators 
for different traversal policies without enumerating them inthe List interface. 
For example, FilteringListIterator might provideaccess only to those elements 
that satisfy specific filteringconstraints. 
Notice that the iterator and the list are coupled, and the client mustknow that 
it is a 
list
that's traversed as opposed to some otheraggregate structure. Hence 
the client commits to a particularaggregate structure. It would be better if we 
could change the aggregateclass without changing client code. We can do this by 
generalizingthe iterator concept to support 
polymorphic iteration

As an example, let's assume that we also have a SkipListimplementation of a list. 
A skiplist [Pug90] is aprobabilistic data structure with characteristics similar 
to balancedtrees. We want to be able to write code that works for both List 
andSkipList objects. 
We define an AbstractList class that provides a common interfacefor manipulating 
lists. Similarly, we need an abstract Iteratorclass that defines a common iteration 
interface. Then we can defineconcrete Iterator subclasses for the different list 
implementations.As a result, the iteration mechanism becomes independent of 
concreteaggregate classes. 
The remaining problem is how to create the iterator. Since we want towrite code 
that's independent of the concrete List subclasses, wecannot simply instantiate 
a specific class. Instead, we make the listobjects responsible for creating their 



Download 4,06 Mb.

Do'stlaringiz bilan baham:
1   ...   191   192   193   194   195   196   197   198   ...   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