Design Patterns : Elements of Reusable Object-Oriented Software


Design Patterns: Elements of Reusable Object-Oriented Software



Download 4,06 Mb.
Pdf ko'rish
bet256/288
Sana07.04.2022
Hajmi4,06 Mb.
#535140
1   ...   252   253   254   255   256   257   258   259   ...   288
Bog'liq
GOF Design Patterns

Design Patterns: Elements of Reusable Object-Oriented Software 
381 
call site less obvious to someone reading the code. Itreally boils down to whether 
you believe function overloading is goodor not. 
11
If we can have 
double
-dispatch, then why not
triple
or 
quadruple
, or any other 
number? Actually,double-dispatch is just a special case of 
multipledispatch
, in 
which the operation is chosen based on any number oftypes. (CLOS actually supports 
multiple dispatch.) Languages thatsupport double- or multiple dispatch lessen 
the need for theVisitor pattern. 


Design Patterns: Elements of Reusable Object-Oriented Software 
382 
Discussion of Behavioral Patterns 
Encapsulating Variation 
Encapsulating variation is a theme of many behavioral patterns. Whenan aspect 
of a program changes frequently, these patterns define anobject that encapsulates 
that aspect. Then other parts of the programcan collaborate with the object 
whenever they depend on that aspect.The patterns usually define an abstract class 
that describes theencapsulating object, and the pattern derives its name from 
thatobject.
12
For example, 

a Strategy object encapsulates an algorithm (Strategy (349)), 

a State object encapsulates a state-dependent behavior (State (338)), 

a Mediator object encapsulates the protocol betweenobjects (Mediator 
(305)), and 

an Iterator object encapsulates the way you access and traverse 
thecomponents of an aggregate object (Iterator (289)). 
These patterns describe aspects of a program that are likely tochange. Most 
patterns have two kinds of objects: the new object(s)that encapsulate the aspect, 
and the existing object(s) that use thenew ones. Usually the functionality of 
new objects would be anintegral part of the existing objects were it not for the 
pattern. Forexample, code for a Strategy would probably be wired into thestrategy's 
Context, and code for a State would be implemented directlyin the state's Context. 
But not all object behavioral patterns partition functionality likethis. For 
example, Chain of Responsibility (251) dealswith an arbitrary number of objects 
(i.e., a chain), all of which mayalready exist in the system.
Chain of Responsibility illustrates another difference in behavioralpatterns: 
Not all define static communication relationships betweenclasses. Chain of 
Responsibility prescribes communication between anopen-ended number of objects. 
Other patterns involve objects that arepassed around as arguments. 

Download 4,06 Mb.

Do'stlaringiz bilan baham:
1   ...   252   253   254   255   256   257   258   259   ...   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