However, you might argue, the object serialization
technique in the .NET Framework allows you to persist objects into
a file stream or other device. Yes, that is true. Nonetheless, the
classes of some objects do not implement the
interface or are not
In addition, there are two other problems to solve.
The second problem has to do with security. You may want to protect some internal state of the object. In other words, you may want to persist some states but not some other states.
The aforementioned issues make the object serialization technique seem useless, doesn't it? Not really. You can still use the .NET Framework object serialization technique with the help of the Memento design pattern.
The idea of the Memento pattern is simple. In this
pattern, the object whose state you want to persist is called the
. To apply the pattern, you
create another object called the
The memento object is an external object that will hold the states
of the originator. Therefore, if you need to save the states of the
The CreateMemento method instantiates a memento object, copies all its states that need to be persisted to the memento object, and then returns the memento object. Therefore, to persist the originator, you call its CreateMemento to obtain a memento object and then serialize the memento object.
method gets the states
back. After you
Clever, isn't it?
In the project in this chapter, you will modify the Memento design pattern a bit. The CreateMemento is called GetMemento , and instead of providing the SetMemento method, you will use a constructor that accepts a memento object. You can then use this constructor to instantiate the object as well as to restore the previous states.
UML is the standard language for object-oriented software visualization, specification, construction, and documentation. Grady Booch, Ivar Jacobson, and Jim Rumbaugh at Rational Software Corporation developed UML, with contributions from other methodologists, software
You can find various documents at http://www.rational.com/uml/index.jsp. A good tutorial book on UML is The Unified Modeling Language
There are three kinds of building blocks in the UML vocabulary:
There are also four kinds of relationships in UML:
The UML includes nine types of diagrams:
Use case diagram
As you can see, UML addresses all the views needed to build and deploy object-oriented applications and therefore is very
You can also use UML to model nonsoftware systems.
The project in this chapter addresses a tiny fraction of UML: the class diagram.