Design Patterns : Elements of Reusable Object-Oriented Software


Structure  Design Patterns: Elements of Reusable Object-Oriented Software



Download 4,06 Mb.
Pdf ko'rish
bet172/288
Sana07.04.2022
Hajmi4,06 Mb.
#535140
1   ...   168   169   170   171   172   173   174   175   ...   288
Bog'liq
GOF Design Patterns

Structure 


Design Patterns: Elements of Reusable Object-Oriented Software 
254 
A typical object structure might look like this: 
Participants 

Handler
(HelpHandler) 
o
defines an interface for handling requests.
o
(optional) implements the successor link. 

ConcreteHandler
(PrintButton, PrintDialog) 
o
handles requests it is responsible for.
o
can access its successor.
o
if the ConcreteHandler can handle the request, it does so; otherwise 
it forwards the request to its successor. 

Client
o
initiates the request to a ConcreteHandler object on the chain. 
Collaborations 

When a client issues a request, the request propagates along the chainuntil 
a ConcreteHandler object takes responsibility for handling it. 
Consequences 
Chain of Responsibility has the following benefits and liabilities: 
1.
Reduced coupling.
The pattern frees an object from knowing which other object 
handles arequest. An object only has to know that a request will be 
handled"appropriately." Both the receiver and the sender have no 
explicitknowledge of each other, and an object in the chain doesn't have 
toknow about the chain's structure. 
As a result, Chain of Responsibility can simplify objectinterconnections. 
Instead of objects maintaining references to allcandidate receivers, they 
keep a single reference to their successor. 


Design Patterns: Elements of Reusable Object-Oriented Software 
255 
2.
Added flexibility in assigning responsibilities to objects.
Chain of 
Responsibility gives you added flexibility in 
distributingresponsibilities among objects. You can add or 
changeresponsibilities for handling a request by adding to or 
otherwisechanging the chain at run-time. You can combine this with 
subclassingto specialize handlers statically. 
3.
Receipt isn't guaranteed.
Since a request has no explicit receiver, there's 
no 
guarantee
it'll be handled

the request can fall off the end of the 
chainwithout ever being handled. A request can also go unhandled when 
thechain is not configured properly. 

Download 4,06 Mb.

Do'stlaringiz bilan baham:
1   ...   168   169   170   171   172   173   174   175   ...   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