Design Patterns : Elements of Reusable Object-Oriented Software


Design Patterns: Elements of Reusable Object-Oriented Software



Download 4,06 Mb.
Pdf ko'rish
bet226/288
Sana07.04.2022
Hajmi4,06 Mb.
#535140
1   ...   222   223   224   225   226   227   228   229   ...   288
Bog'liq
GOF Design Patterns

Design Patterns: Elements of Reusable Object-Oriented Software 
337 
}; 
The following code creates an AnalogClock and aDigitalClock that always show the 
same time: 
ClockTimer* timer = new ClockTimer; 
AnalogClock* analogClock = new AnalogClock(timer); 
DigitalClock* digitalClock = new DigitalClock(timer); 
Whenever the timer ticks, the two clocks will be updatedand will redisplay 
themselves appropriately. 
Known Uses 
The first and perhaps best-known example of the Observer pattern appearsin 
Smalltalk Model/View/Controller (MVC), the user interface framework in the 
Smalltalkenvironment [KP88]. MVC's Model class plays the role ofSubject, while 
View is the base class for observers. Smalltalk,ET++ [WGM88], and the THINK class 
library [Sym93b] provide ageneral dependency mechanism by putting Subject and 
Observer interfacesin the parent class for all other classes in the system. 
Other user interface toolkits that employ this pattern areInterViews [LVC89], 
the AndrewToolkit [P+88], and Unidraw [VL90]. InterViewsdefines Observer and 
Observable (for subjects) classes explicitly.Andrew calls them "view" and "data 
object," respectively. Unidrawsplits graphical editor objects into View (for 
observers) and Subjectparts. 
Related Patterns 
Mediator (305): Byencapsulating complex update semantics, the ChangeManager acts 
asmediator between subjects and observers. 
Singleton (144):The ChangeManager may use the Singleton pattern to make it 
uniqueand globally accessible. 


Design Patterns: Elements of Reusable Object-Oriented Software 
338 
State 
Intent 
Allow an object to alter its behavior when its internal state changes.The object 
will appear to change its class. 

Download 4,06 Mb.

Do'stlaringiz bilan baham:
1   ...   222   223   224   225   226   227   228   229   ...   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