Memorandum (owner of design)
The owner memorandum is a Patron of design Logiciel which provides the manner of returning an object in a preceding state (return postpones) without violating the principle of encapsulation.
The memorandum is used by two objects: the creator and the guard. The creator is an object having an internal state (state to be safeguarded). The guard will act on the creator, while preserving the possibility of retrogressing. The guard then requests from the creator the memorandum object. He carries out the operation (or sequence of operations) desired. In order to allow the back return before the operations, the memorandum is turned over to the creator. The memorandum object even is opaque (the guard cannot, or would not have, to modify it). During use of this owner, a very detailed attention must be taken to check if the creator modifies other objects or resources - the owner memorandum must operate on only one object.
It should be stressed that the fact of safeguarding the state interns creative object must be carried out without breaking the principle of encapsulation. That is not always possible (example: SmallTalk does not allow it in a direct way).
Traditional examples of the owner memorandum include the generator of pseudo-random numbers, the machine in finished states, the function " Annulation" /" Undo".
Example
This example programmed in Java illustrates the use of the pattern Memento to carry out a type order of cancel.
The result is: Originator: state affects a: State1 Originator: state affects a: State2 Originator: safeguard in the memorandum. Originator: state affects a: State3 Originator: safeguard in the memorandum. Originator: state affects a: State4 Originator: State after restoration: State3
| Random links: | LÃmite (matemáticas) | Saint-Julien-on-Calonne | Thiénans | Megapodius eremita | ACT New Zealand | Antoine Pastorana | Harry_Williams |