Design Patterns : Elements of Reusable Object-Oriented Software


Design Patterns: Elements of Reusable Object-Oriented Software



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

Design Patterns: Elements of Reusable Object-Oriented Software 
384 
Decoupling Senders and Receivers 
When collaborating objects refer to each other directly, they becomedependent 
on each other, and that can have an adverse impact on thelayering and reusability 
of a system. Command, Observer, Mediator,and Chain of Responsibility address how 
you can decouple senders andreceivers, but with different trade-offs. 
The Command pattern supports decoupling by using a Command object todefine the 
binding between a sender and receiver: 
The Command object provides a simple interface for issuing the request(that is, 
the Execute operation). Defining the sender-receiverconnection in a separate 
object lets the sender work with differentreceivers. It keeps the sender decoupled 
from the receivers, makingsenders easy to reuse. Moreover, you can reuse the 
Command object toparameterize a receiver with different senders. The Command 
patternnominally requires a subclass for each sender-receiver connection,although 
the pattern describes implementation techniques that avoidsubclassing. 
The Observer pattern decouples senders (subjects) from receivers(observers) by 
defining an interface for signaling changes insubjects. Observer defines a looser 
sender-receiver binding thanCommand, since a subject may have multiple observers, 
and their numbercan vary at run-time. 


Design Patterns: Elements of Reusable Object-Oriented Software 
385 
The Subject and Observer interfaces in the Observer pattern aredesigned for 
communicating changes. Therefore the Observer pattern isbest for decoupling 
objects when there are data dependencies betweenthem. 
The Mediator pattern decouples objects by having them refer to eachother indirectly 
through a Mediator object. 
A Mediator object routes requests between Colleague objects andcentralizes their 
communication. Consequently, colleagues can onlytalk to each other through the 
Mediator interface. Because thisinterface is fixed, the Mediator might have to 
implement its owndispatching scheme for added flexibility. Requests can be encoded 
andarguments packed in such a way that colleagues can request anopen-ended set 
of operations. 



Download 4,06 Mb.

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