Skip to content

Commit eb75773

Browse files
authored
Added FAQ on Memento pattern
Difference between java Serialization and Memento pattern added
1 parent 5610092 commit eb75773

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

faq.md

+8
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,11 @@ Flyweight.
6565
### Q7: What are the differences between FluentInterface and Builder patterns? {#Q7}
6666

6767
Fluent interfaces are sometimes confused with the Builder pattern, because they share method chaining and a fluent usage. However, fluent interfaces are not primarily used to create shared (mutable) objects, but to configure complex objects without having to respecify the target object on every property change.
68+
69+
### Q8: What is the difference between java.io.Serialization and Memento pattern? {#Q8}
70+
71+
Memento is typically used to implement rollback/save-point support. Example we might want to mark the state of an object at a point in time, do some work and then decide to rollback to the previous state.
72+
73+
On the other hand serialization may be used as a tool to save the state of an object into byte[] and preserving the contents in memory or disk. When someone invokes the memento to revert object's previous state then we can deserialize the information stored and recreate previous state.
74+
75+
So Memento is a pattern and serialization is a tool that can be used to implement this pattern. Other ways to implement the pattern can be to clone the contents of the object and keep track of those clones.

0 commit comments

Comments
 (0)