Design Patterns : Elements of Reusable Object-Oriented Software


memento is an object that  stores a snapshot of theinternal state of another object  — the memento's  originator



Download 4,06 Mb.
Pdf ko'rish
bet214/288
Sana07.04.2022
Hajmi4,06 Mb.
#535140
1   ...   210   211   212   213   214   215   216   217   ...   288
Bog'liq
GOF Design Patterns

memento
is an object that 
stores a snapshot of theinternal state of another object 

the memento's 
originator

The undo mechanism will request a mementofrom the originator when it needs to 
checkpoint the originator'sstate. The originator initializes the memento with 
information thatcharacterizes its current state. Only the originator can store 
andretrieve information from the memento

the memento is "opaque" toother objects. 
In the graphical editor example just discussed, the ConstraintSolver can actas 
an originator. The following sequence of events characterizes theundo process: 
1.
The editor requests a memento from the ConstraintSolver as aside-effect 
of the move operation. 
2.
The ConstraintSolver creates and returns a memento, an instance of aclass 
SolverState in this case. A SolverState memento contains datastructures 
that describe the current state of the ConstraintSolver'sinternal 
equations and variables. 
3.
Later when the user undoes the move operation, the editor gives 
theSolverState back to the ConstraintSolver. 
4.
Based on the information in the SolverState, the ConstraintSolverchanges 
its internal structures to return its equations and variablesto their exact 
previous state. 
This arrangement lets the ConstraintSolver entrust other objects withthe 
information it needs to revert to a previous state withoutexposing its internal 
structure and representations. 


Design Patterns: Elements of Reusable Object-Oriented Software 
318 
Applicability 
Use the Memento pattern when 

a snapshot of (some portion of) an object's state must be saved sothat it 
can be restored to that state later
and

a direct interface to obtaining the state would exposeimplementation 
details and break the object's encapsulation. 

Download 4,06 Mb.

Do'stlaringiz bilan baham:
1   ...   210   211   212   213   214   215   216   217   ...   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