Design Patterns : Elements of Reusable Object-Oriented Software


Design Patterns: Elements of Reusable Object-Oriented Software



Download 4,06 Mb.
Pdf ko'rish
bet219/288
Sana07.04.2022
Hajmi4,06 Mb.
#535140
1   ...   215   216   217   218   219   220   221   222   ...   288
Bog'liq
GOF Design Patterns

Design Patterns: Elements of Reusable Object-Oriented Software 
325 
7
Note that our example deletes the state object at the end of the iteration. 
But delete won't get called if ProcessItem throws an exception, thus creating 
garbage. This is a problem in C++ but not in Dylan, which has garbage collection. 
We discuss a solution to this problem on page 299. 


Design Patterns: Elements of Reusable Object-Oriented Software 
326 
Observer 
Intent 
Define a one-to-many dependency between objects so that when oneobject changes 
state, all its dependents are notified and updatedautomatically. 
Also Known As 
Dependents, Publish-Subscribe 
Motivation 
A common side-effect of partitioning a system into a collection ofcooperating 
classes is the need to maintain consistency betweenrelated objects. You don't 
want to achieve consistency by making theclasses tightly coupled, because that 
reduces their reusability. 
For example, many graphical user interface toolkits separate thepresentational 
aspects of the user interface from the underlyingapplication data [KP88, LVC89, 
P+88, WGM88].Classes defining application data and presentations can be 
reusedindependently. They can work together, too. Both a spreadsheet objectand 
bar chart object can depict information in the same application dataobject using 
different presentations. The spreadsheet and the bar chartdon't know about each 
other, thereby letting you reuse only the one youneed. But they 
behave
as though 
they do. When the user changes theinformation in the spreadsheet, the bar chart 
reflects the changesimmediately, and vice versa. 


Design Patterns: Elements of Reusable Object-Oriented Software 
327 
This behavior implies that the spreadsheet and bar chart are dependenton the data 
object and therefore should be notified of any change inits state. And there's 
no reason to limit the number of dependentobjects to two; there may be any number 
of different user interfacesto the same data. 
The Observer pattern describes how to establish these relationships.The key 
objects in this pattern are 

Download 4,06 Mb.

Do'stlaringiz bilan baham:
1   ...   215   216   217   218   219   220   221   222   ...   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