Class extensions are the simplest and most important way of customizing geodatabase behavior. In particular, they provide the following capabilities:
- Complex validation rules (through IObjectClassValidation)
- Handling of edit events (through IObjectClassEvents and IRelatedObjectClassEvents)
- Enhancement of the Attributes dialog box (through the IObjectInspector interfacesee the 'Extending the editor' section)
- Customized rendering of feature classes (through the IFeatureClassDraw interfacesee the 'Extending the display' section)
- Automated creation of preconfigured tables and feature classes (through IObjectClassDescription and IFeatureClassDescription)
- Storage of arbitrary objects and data with an object class (through extension properties)
Class extensions are at their best when used for important business rules that can be simply implemented without serious performance considerations.
These capabilities could often instead be provided in application code; for example the handling of edit events could be implemented as an editor extension for the ArcMap application. There are many advantages and disadvantages of class extensions relative to application customization. These are summarized in the following table.
|Class extensions||Application customization|
Database customization is always available. It is not dependent on a particular application such as ArcMap being present. This can be important for feature classes accessed from ArcGIS Engine or ArcGIS Server.
Business logic is stored closely to the data.
Easy to implement and tightly integrated with the application user interface.
If customization fails then user can access important data with other tools.
The DLL is only required by those users who need the specific customization functionality.
All ArcGIS users require access to the customization DLL, even to view the data.
If the customization fails at runtime, the data cannot be accessed from ArcGIS (this can also be considered an advantage that ensures data integrity).
The developer cannot make any assumptions that a particular application will be running. This can limit functionality.
An object class can only have one class extension.
You cannot easily extend annotation feature classes or dimension feature classes.
There is a possibility that users could avoid business rules by running the application without the customization.
Implementation is sometimes duplicated among several applications.
The customization is only available when the application is running.
See Also Pipe Validation Class Extension Example, Managing Class Extensions, Timestamper Class Extension Example, Class Extensions and Relationship Classes, and Class Extensions for Annotation and Dimensions.