next up previous contents
Next: The method finder Up: Objects In C Previous: The template device

Methods

Methods are C functions but with a difference. The main difference is that they are accessed via a method_finder which uses run-time binding and not by being called directly like with traditional functions which implies compile-time binding. Methods are identified by a symbol representing an integer. All symbols start with the preffix DevMethod. The naming convention is to distinguish compound words by capital letters. The symbols for methods are stored in the DevServer.h file - new methods can be added here or in the public include file.

Methods, like traditional C functions, do not have a fixed argument syntax. A function implementing a method may use any argument syntax. The application executing the method should know what arguments are required, their type and in what order to pass them.

All methods should return an integer value which reflects the execution status of the method. For the return value the following convention has been adopted - DS_NOTOK is returned if the method fails to execute correctly, and DS_OK if it succeeds. These symbols are defined in the DevServer.h file.

All methods should be defined as being static in C i.e. only directly accessible from within the classes source code file. Doing this forces applications and subclasses to use the method_finder to execute a class's methods. This is what is commonly termed code-hiding and is one of the advantages of Object Oriented Programming. Another advantage of the method_finder is that it supports code inheritance. A subclass can inherit code from its superclass(es). This is the case for all subclasses of the DevServerClass for example - they inherit the network interface code which is implemented in DevServerClass.





Andy Goetz
Tue Jan 28 13:58:13 MET 1997