Memento Kendra Kachelein Maureen Thomas. Definition The memento captures and externalizes an object’s internal state, so the object can be restored to.

Slides:



Advertisements
Similar presentations
Based on Java Software Development, 5th Ed. By Lewis &Loftus
Advertisements

And so to Code. Forward, Reverse, and Round-Trip Engineering Forward Engineering Reverse Engineering Round-Trip Engineering.
ARCH-01: Introduction to the OpenEdge™ Reference Architecture Don Sorcinelli Applied Technology Group.
Requirements and Design
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter Chapter 4 Defining Your Own Classes.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter Chapter 4 Defining Your Own Classes.
1 Objects and Classes Introduction to Classes Object Variables and Object References Instantiating Objects Using Methods in Objects Reading for this Lecture:
ECE122 L6: Problem Definition and Implementation February 15, 2007 ECE 122 Engineering Problem Solving with Java Lecture 6 Problem Definition and Implementation.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter Chapter 4 Defining Your Own Classes.
UML Class Diagram: class Rectangle
CS 2511 Fall Features of Object Oriented Technology  Abstraction Abstract class Interfaces  Encapsulation Access Specifiers Data Hiding  Inheritance.
Week 3 Recap CSE 115 – Spring Constructor Special capability of a class that sets up the initial state of the object. Constructor definitions are.
Memento Page 283 Jason Penny. Memento Behavioral Pattern Behavioral Pattern Intent: Intent: Without violating encapsulation, capture and externalize an.
COMP 110 Information Hiding and Encapsulation Tabitha Peck M.S. February 25, 2008 MWF 3-3:50 pm Philips
Behavioral Pattern: Memento C h a p t e r 5 – P a g e 179 Objects frequently expose only some of their internal state using public methods, but there.
BDP Behavioral Pattern. BDP-2 Behavioral Patters Concerned with algorithms & assignment of responsibilities Patterns of Communication between Objects.
Outline Introduction Problem Statement Object-Oriented Design Aspect-Oriented Design Conclusion Demo.
Architectural Styles, Design Patterns, and Objects Robert T. Monroe (Doctoral Candiate) Andrew Kompanek (Research Programmer) Ralph Melton (Graduate Student)
CS212: Object Oriented Analysis and Design Lecture 4: Objects and Classes - I.
CSC 520 – Advanced Object Oriented Programming, Fall, 2010 Thursday, September 2, Week 4 Design by Contract, Java Exceptions, Eventing, Finding the Classes,
Python File Handling. In all the programs you have made so far when program is closed all the data is lost, but what if you want to keep the data to use.
Chapter 9: The Iterator Pattern
ECE450 - Software Engineering II1 ECE450 – Software Engineering II Today: Design Patterns VII Observer, Command, and Memento.
Design Patterns CSCI 5801: Software Engineering. Design Patterns.
Software Design Patterns (1) Introduction. patterns do … & do not … Patterns do... provide common vocabulary provide “shorthand” for effectively communicating.
Objects to Protect Private Details: Memento and Iterator Snarf the iterator code for today’s class.
CSSE501 Object-Oriented Development. Chapter 4: Classes and Methods  Chapters 4 and 5 present two sides of OOP: Chapter 4 discusses the static, compile.
Designing Classes Chapter 3. 2 Chapter Contents Encapsulation Specifying Methods Java Interfaces Writing an Interface Implementing an Interface An Interface.
Design Patterns CSIS 3701: Advanced Object Oriented Programming.
Database Design Some of these slides are derived from IBM/Rational slides from courses on UML and object-oriented design and analysis. Copyright to the.
Programming with Java © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 1 McGraw-Hill/Irwin Chapter 5 Creating Classes.
Joe Boylan David Guzman Oscar Ontiveros Fabian Pizana Jose Segura Adrian Veliz.
CSE 332: Design Patterns Review: Design Pattern Structure A design pattern has a name –So when someone says “Adapter” you know what they mean –So you can.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 7: Introduction to Classes and Objects Starting Out with C++ Early.
Memento Design Pattern Lee Lisle. Overview Why would we use Memento? Examples of Memento How to implement Memento.
Bridge Bridge is used when we need to decouple an abstraction from its implementation so that the two can vary independently. This type of design pattern.
1 Classes, Encapsulation, Methods and Constructors Class definitions Scope of Data –Instance data –Local data The this Reference Encapsulation and Java.
Behavioural Patterns GoF pg Iterator GoF pg. 257 – 271 Memento GoF pg By: Dan Sibbernsen.
Matthew Small Introduction to Object-Oriented Programming.
The Memento Pattern (Behavioral) ©SoftMoore ConsultingSlide 1.
Chapter 7 Classes and Methods III: Static Methods and Variables Lecture Slides to Accompany An Introduction to Computer Science Using Java (2nd Edition)
Kyung Hee University Class Diagramming Notation OOSD 담당조교 석사과정 이정환.
The radio  Has a case  The case separates the controls on the outside (the client interface) from the electronic guts inside (the implementation).
OBSERVER PATTERN OBSERVER PATTERN Presented By Presented By Ajeet Tripathi ISE
PIMPL Idiom Encapsulating Implementation. Forward Declaration Revisited forward class declaration – names the class, does not provide definition class.
Jim Fawcett CSE776 – Design Patterns Summer 2005
How to be a Good Developer
Delegates and Events 14: Delegates and Events
Observer Design Pattern
Observer Design Pattern
Design Patterns Part 2: Builder & Memento
Memento Pattern F 羅世東 F 李天彥 F 鄧義佐 F 林尚霖
Memento Design Pattern
What’s a Design Pattern?
UML Class Diagram: class Rectangle
Behavioral and Structural Patterns
Subprograms and Programmer Defined Data Type
State Design Pattern 1.
Properties 7: Properties Programming C# © 2003 DevelopMentor, Inc.
CSE 1020:Programming by Delegation
Observer Pattern 1.
Prototype Pattern 1.
Review: Design Pattern Structure
Polymorphism Pattern.
The iterator and memento patterns
Flyweight Pattern 1.
Defining Classes and Methods
Design Patterns Part 2: Factory, Builder, & Memento
Memento Pattern 1.
Software Design Lecture : 39.
Presentation transcript:

Memento Kendra Kachelein Maureen Thomas

Definition The memento captures and externalizes an object’s internal state, so the object can be restored to that state later.

Applicability Use the Memento pattern when: A snapshot of an object’s state must be saved so that it can be restore to that state later, and A direct interface to obtaining the state would expose implementation details and break the object’s encapsulation

Participants There are 3 participants in the Memento pattern: Originator: whose state has to be maintained Memento: stores the state of the Originator object Caretaker: has a handle to the Memento

Example Originator Caretaker Memento

UML Diagram Originator - State +SetMemento(in Memento) +CreateMemento() Memento - State +GetState() +SetState() Caretaker Owner - State +DepositCombination(in Memento) +WriteCombination() Safety Deposit - State +GetCombo() +GiveCombo() Security Guard Class Example:

Source Code Implementation public class Owner { private int combination public safetyDeposit getCombo() { return new saftetyDeposit(this); } public void giveCombo(safetyDeposit sd) { combination = sd.combination; }