25.01.2015 Views

Using Caché Objects - InterSystems Documentation

Using Caché Objects - InterSystems Documentation

Using Caché Objects - InterSystems Documentation

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

22<br />

Dynamic Dispatch<br />

<strong>Caché</strong> classes can include support for what is called “dynamic dispatch.” If dynamic dispatch<br />

is in use and a program references a property or method that is not part of the class definition,<br />

then a method (called a “dispatch method” ) is called that attempts to resolve the undefined<br />

method or property. For example, dynamic dispatch can return a value for a property that is<br />

not defined or it can invoke a method for a method that isn't implemented. The dispatch destination<br />

is dynamic in that it does not appear in the class descriptor and is not resolved until<br />

runtime.<br />

22.1 How Dynamic Dispatch Happens<br />

<strong>Caché</strong> makes a number of dispatch methods available that you can implement. Each of these<br />

methods attempts to resolve an element that is missing under different circumstances.<br />

If you implement a dispatch method, it has the following effects:<br />

• During application execution, if <strong>Caché</strong> encounters an element that is not part of the<br />

compiled class, it invokes the dispatch method to try to resolve the encountered element.<br />

• The application code that uses the class does not do anything special to make this happen.<br />

<strong>Caché</strong> automatically checks for the existence of the dispatch method and, if that method<br />

is present, invokes it.<br />

<strong>Using</strong> <strong>Caché</strong> <strong>Objects</strong> 187

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!