



































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
An overview of the memento pattern, its goals, benefits, considerations, and implementation using java serialization. The memento pattern is a behavioral design pattern that enables saving and restoring the important state of an object while maintaining its encapsulation. Java serialization is a popular approach for saving and restoring connected groups of objects. The process of making a memento in java, shallow versus deep copies, and creating game snapshot mementos. It also explains the concept of cloning objects and the differences between in-memory and saved copies.
Typology: Study notes
1 / 43
This page cannot be seen from the preview
Don't miss anything!




































NIVERSITY OFNIVERSITY OF
ASSACHUSETTS ASSACHUSETTS
MHERST MHERST •
Department of Computer Science Department of Computer Science
NIVERSITY OFNIVERSITY OF
ASSACHUSETTS ASSACHUSETTS
MHERST MHERST •
Department of Computer Science Department of Computer Science
NIVERSITY OFNIVERSITY OF
ASSACHUSETTS ASSACHUSETTS
MHERST MHERST •
Department of Computer Science Department of Computer Science
BreakoutGame/BOEngine //when save is requestedGameSnapshot snapshot =
GameSnapshot.makeSnapshot(
(game, gameState); // **
//when restoring (a new game)… = new BreakoutGame(
gameEngine, snapshot); // ***
BreakoutGame/GameState GameState snapshotvoid saveGame() {
//gather state: code at **
} BreakoutGame(Game Engine e,
GameSnapshot s); {
//restore state: code at ***
} // do other Key Object stuff
GameSnapshot savedBallsavedBlocks…
NIVERSITY OFNIVERSITY OF
ASSACHUSETTS ASSACHUSETTS
MHERST MHERST •
Department of Computer Science Department of Computer Science
NIVERSITY OFNIVERSITY OF
ASSACHUSETTS ASSACHUSETTS
MHERST MHERST •
Department of Computer Science Department of Computer Science
NIVERSITY OFNIVERSITY OF
ASSACHUSETTS ASSACHUSETTS
MHERST MHERST •
Department of Computer Science Department of Computer Science
NIVERSITY OFNIVERSITY OF
ASSACHUSETTS ASSACHUSETTS
MHERST MHERST •
Department of Computer Science Department of Computer Science
NIVERSITY OFNIVERSITY OF
ASSACHUSETTS ASSACHUSETTS
MHERST MHERST •
Department of Computer Science Department of Computer Science
NIVERSITY OFNIVERSITY OF
ASSACHUSETTS ASSACHUSETTS
MHERST MHERST •
Department of Computer Science Department of Computer Science
NIVERSITY OFNIVERSITY OF
ASSACHUSETTS ASSACHUSETTS
MHERST MHERST •
Department of Computer Science Department of Computer Science
NIVERSITY OFNIVERSITY OF
ASSACHUSETTS ASSACHUSETTS
MHERST MHERST •
Department of Computer Science Department of Computer Science
NIVERSITY OFNIVERSITY OF
ASSACHUSETTS ASSACHUSETTS
MHERST MHERST •
Department of Computer Science Department of Computer Science
NIVERSITY OFNIVERSITY OF
ASSACHUSETTS ASSACHUSETTS
MHERST MHERST •
Department of Computer Science Department of Computer Science
NIVERSITY OFNIVERSITY OF
ASSACHUSETTS ASSACHUSETTS
MHERST MHERST •
Department of Computer Science Department of Computer Science