Memento Design Pattern

  1. Originator: This is the place where save the current and previous states of original object through set operations.
  2. Memento: This is the place where we can save the internal state of originator object.
  3. Care taker: This is the place where we store the mementos for later use.
  • Provide restore or revert abilities.
  • Keep the saved state and object separately and thus provides cohesion.
  • It can be time consuming task.
  • save() is used to pass the current state of the Mark for Care Taker class (in this case it is MarksHistory class).
  • revert() is used to roll back the state of Mark.

Stay Safe !!!

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store