Design Patterns in the VCL -- DFM as Memento


Revealing the Magician's Secrets

  1. Component Palette ==> Prototype

  2. Panel ==> Composite

  3. .DFM file ==> Memento

Problem

How do I externalize the state of a class (e.g., for persistence, streaming, or recovery) without violating its encapsulation of private implementation details?

Solution

Memento suggests creating an "opaque" external representation for this encapsulated state, readable and writable only by the class which creates it.

Consequences

  • Because the Memento is opaque to the client, the creator class can safely externalize its state to the Memento, and hand it off to the client, without exposing the client to any encapsulated implementation details.

  • Other objects can "hold" the Memento for the creator (or by extension, persist it in binary format), and return it to the creator on demand.

[ Next | Previous | Top | Outline | Glossary | Links ]


These pages maintained by Tres Seaver of Palladion Software . Copyright 1998, all rights reserved.