There are many reasons why the product uses first-class replacers and strategies, rather than having the Swapper interact directly with the object to be swapped.
There are two different kinds of replacers that implement the behavior
presented in Dumping replacement. The table below lists the types of replacers and the
kind of replacement they provide.
Replacer Type | Replacement Provided |
---|---|
Class Based Replacer | Object replacement based on the class of the original (Class-based replacement) |
Instance Variable Replacer | Replacement of individual instance variables of the original object (Instance-variable-based replacement) |
An ObjectDumper can be customized with replacers for each of the types above. You should use ObjectDumper instance methods classBasedReplacer: and instVarReplacer:.
For each kind of dumping replacement listed above, an abstract class exists. They are named EswClassBasedReplacer and EswInstVarBasedReplacer. These classes let you subclass replacers and plug instances of the new subclasses in instances of ObjectDumper. The protocol that each type of replacer should implement is listed in the VisualAge Migration Guide.
Only one kind of loading replacement, class-based replacement, was presented in Loading replacement. One kind of replacer, the loading replacer, implements it. An ObjectLoader can be customized with a loading replacer by using ObjectLoader instance method loadingReplacer:. This message plugs a new replacer in the ObjectLoader. There is an abstract class for a loading replacer, EswLoadingReplacer. This class lets you subclass a loading replacer and plug an instance of the new subclass in instances of ObjectLoader.