RAD Studio
ContentsIndex
PreviousUpNext
Interface Version Numbers

If you look closely at the declarations of some of the interfaces, such as IOTAMessageServices, you will see that they inherit from other interfaces with similar names, such as IOTAMessageServices50, which inherits from IOTAMessageServices40. This use of version numbers helps insulate your code from changes between releases of Delphi. 

The Tools API follows the basic principle of COM, namely, that an interface and its GUID never change. If a new release adds features to an interface, the Tools API declares a new interface that inherits from the old one. The GUID remains the same, attached to the old, unchanged interface. The new interface gets a brand new GUID. Old wizards that use the old GUIDs continue to work. 

The Tools API also changes interface names to try to preserve source-code compatibility. To see how this works, it is important to distinguish between the two kinds of interfaces in the Tools API: Borland-implemented and user-implemented. If the IDE implements the interface, the name stays with the most recent version of the interface. The new functionality does not affect existing code. The old interfaces have the old version number appended. 

For a user-implemented interface, however, new member functions in the base interface require new functions in your code. Therefore, the name tends to stick with the old interface, and the new interface has a version number tacked onto the end. 

For example, consider the message services. Delphi 6 introduced a new feature: message groups. Therefore, the basic message services interface required new member functions. These functions were declared in a new interface class, which retained the name IOTAMessageServices. The old message services interface was renamed to IOTAMessageServices50 (for version 5). The GUID of the old IOTAMessageServices is the same as the GUID of the new IOTAMessageServices50 because the member functions are the same. 

Consider IOTAIDENotifier as an example of a user-implemented interface. Delphi 5 added new overloaded functions: AfterCompile and BeforeCompile. Existing code that used IOTAIDENotifier did not need to change, but new code that required the new functionality had to be modified to override the new functions inherited from IOTAIDENotifier50. Version 6 did not add any more functions, so the current version to use is IOTAIDENotifier50

The rule of thumb is to use the most-derived class when writing new code. Leave the source code alone if you are merely recompiling an existing wizard under a new release of Delphi.

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!