Using Caché Objects - InterSystems Documentation
Using Caché Objects - InterSystems Documentation
Using Caché Objects - InterSystems Documentation
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
18<br />
Method Generators<br />
A powerful feature of <strong>Caché</strong> Object is the ability to define method generators: small programs<br />
that are invoked by the Class Compiler to generate the runtime code for a method.<br />
Method generators are used extensively within the <strong>Caché</strong> Class Library. For example, most<br />
of the methods of the %Persistent class are implemented as method generators. This makes<br />
it possible to give each persistent class customized storage code, instead of less efficient,<br />
generic code. Most of the <strong>Caché</strong> data type class methods are also implemented as method<br />
generators. Again, this gives these classes the ability to provide custom implementations that<br />
depend on the context in which they are used.<br />
You can use method generators within your own applications. A common usage is to define<br />
one or more “utility” superclasses that provide specialized methods for the subclasses that<br />
use them. The method generators within these utility classes create special code based on the<br />
definition (properties, methods, parameter values, etc.) of the class that uses them. Good<br />
examples of this technique are the %Populate and %XML.Adaptor classes provided within the<br />
<strong>Caché</strong> library.<br />
18.1 Defining a Method Generator<br />
A method generator is simply a method of a <strong>Caché</strong> class that has its CodeMode keyword set<br />
to “objectgenerator” :<br />
<strong>Using</strong> <strong>Caché</strong> <strong>Objects</strong> 155