Design Patterns : Elements of Reusable Object-Oriented Software


Design Patterns: Elements of Reusable Object-Oriented Software



Download 4,06 Mb.
Pdf ko'rish
bet184/288
Sana07.04.2022
Hajmi4,06 Mb.
#535140
1   ...   180   181   182   183   184   185   186   187   ...   288
Bog'liq
GOF Design Patterns

Design Patterns: Elements of Reusable Object-Oriented Software 
272 
}; 
The key to the MacroCommand is its Execute memberfunction. This traverses all 
the subcommands and performsExecute on each of them. 
void MacroCommand::Execute () { 
ListIterator i(_cmds); 
for (i.First(); !i.IsDone(); i.Next()) { 
Command* c = i.CurrentItem(); 
c->Execute(); 


Note that should the MacroCommand implement anUnexecute operation, then its 
subcommands must beunexecuted in 
reverse
order relative to 
Execute'simplementation. 
Finally, MacroCommand must provide operations to manage itssubcommands. The 
MacroCommand is also responsible fordeleting its subcommands. 
void MacroCommand::Add (Command* c) { _cmds->Append(c); } 
void MacroCommand::Remove (Command* c) { _cmds->Remove(c); } 
Known Uses 
Perhaps the first example of the Command pattern appears in a paper byLieberman 
[Lie85]. MacApp [App89] popularizedthe notion of commands for implementing 
undoable operations.ET++ [WGM88], InterViews [LCI+92], andUnidraw [VL90] also 
define classes that follow theCommand pattern. InterViews defines an Action 
abstract class thatprovides command functionality. It also defines an 
ActionCallbacktemplate, parameterized by action method, that can instantiate 
commandsubclasses automatically. 
The THINK class library [Sym93b] also uses commands to supportundoable actions. 
Commands in THINK are called "Tasks." Taskobjects are passed along a Chain of 
Responsibility (251) for consumption. 
Unidraw's command objects are unique in that they can behave likemessages. A 
Unidraw command may be sent to another object forinterpretation, and the result 
of the interpration varies with thereceiving object. Moreover, the receiver may 
delegate theinterpretation to another object, typically the receiver's parent 
in alarger structure as in a Chain of Responsibility. The receiver of aUnidraw 
command is thus computed rather than stored. Unidraw'sinterpretation mechanism 
depends on run-time type information. 



Download 4,06 Mb.

Do'stlaringiz bilan baham:
1   ...   180   181   182   183   184   185   186   187   ...   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