Design Patterns : Elements of Reusable Object-Oriented Software


Design Patterns: Elements of Reusable Object-Oriented Software



Download 4,06 Mb.
Pdf ko'rish
bet233/288
Sana07.04.2022
Hajmi4,06 Mb.
#535140
1   ...   229   230   231   232   233   234   235   236   ...   288
Bog'liq
GOF Design Patterns

Design Patterns: Elements of Reusable Object-Oriented Software 
347 
when the selection tool is active we select shapes;and so forth. We can use the 
State pattern to change the editor'sbehavior depending on the current tool. 
We can define an abstract Tool class from which to define subclassesthat implement 
tool-specific behavior. The drawing editor maintains acurrent Tool object and 
delegates requests to it. It replaces thisobject when the user chooses a new tool, 
causing the behavior of thedrawing editor to change accordingly.
This technique is used in both the HotDraw [Joh92] and Unidraw [VL90] drawing 
editor frameworks. It allows clients to define new kinds of tools easily. In HotDraw, 
the DrawingController class forwards the requests to the current Tool object. 
In Unidraw, the corresponding classes are Viewer and Tool. The following class 
diagram sketches the Tool and DrawingController interfaces: 
Coplien's Envelope-Letter idiom [Cop92] is related toState. Envelope-Letter is 
a technique for changing an object's class atrun-time. The State pattern is more 
specific, focusing on how to dealwith an object whose behavior depends on its 
state. 
Related Patterns 
The Flyweight (218) pattern explains when and how State objects can be shared. 
State objects are often Singletons (144). 
8
This example is based on the TCP connection protocoldescribed by Lynch andRose 
[LR93]. 


Design Patterns: Elements of Reusable Object-Oriented Software 
348 
9
This makes each TCPState subclass a Singleton (see Singleton (144)). 


Design Patterns: Elements of Reusable Object-Oriented Software 
349 
Strategy 
Intent 
Define a family of algorithms, encapsulate each one, and make theminterchangeable. 
Strategy lets the algorithm vary independently fromclients that use it. 

Download 4,06 Mb.

Do'stlaringiz bilan baham:
1   ...   229   230   231   232   233   234   235   236   ...   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