Extending ArcObjects  

Choosing your Development Environment

This topic is relevant for the following:
Product(s): ArcGIS Desktop: All
Version(s): 9.0, 9.1, 9.2
Language(s): VB6, VC++
Experience level(s): Intermediate to advanced



In this section:

  1. Development Environments in Extending ArcObjects
  2. Choosing a development environment based on your design requirements
  3. Visual Basic 6 editions
  4. Topics relevant to particular environments

Development Environments in Extending ArcObjects

To consume the ArcObjects object libraries and create customizations for ArcGIS, you can use any COM-compliant development environment. You may have developed your customizations using the development environment with which you are most familiar, but you should be aware that different development environments offer different advantages and disadvantages. To summarize, for beginner to advanced ArcObjects programmers, VB  is an ideal environment, offering rapid application development (RAD) and simple syntax. However, this simplicity is achieved at the price of certain limitations (as you will see throughout this section). VC++ requires the practice of much more rigorous programming, and it is therefore recommended that VC++ development with ArcObjects is best achieved with several years of VC++ experience.

The customizations explored in this book focus on the creation of custom components, extending the object models of ArcGIS. For this type of development you will need to consider your choice of development environment carefully, as your options may be constrained based on the type of development you want to undertake.

The choice of development environment is more critical when extending the ArcGIS object models, compared to script-type customizations.

Visual Basic 6 and Visual C++

Many of the examples described throughout Extending ArcObjects are possible in a number of development environments. This book concentrates on the two environments that are used by the majority of ArcObjects developers, Visual Basic 6, and Visual C++.

(Throughout this book, 'VB' refers to Visual Basic version 6. The abbreviation VB.NET may be used for information relating specifically to Visual Basic .NET).


Choosing a development environment based on your design requirements

The ArcObjects libraries were written in VC++. The interfaces in these libraries, through which all communication with COM objects is performed, were defined using IDL. Therefore, all the features supported by both Visual C++ and IDL may be found in ArcObjects interfaces.

The interfaces in ArcObjects were defined with IDL.

Although COM is a binary standard and, therefore, largely language-independent, differences in the features supported by the common development environments result in certain limitations when creating custom components. Before you start coding, you need to decide which development environment you require for your project.

Below are three main requirements that may affect your choice—, you must be able to create a COM class, you may possibly need to inherit from another class, and you must be able to implement the required interfaces.

COM class creation

Your first step to extending the ArcObjects model is to create your own COM class. Most object-oriented development environments allow the creation of classes, for example, VB, VC++, Visual Basic for Applications (VBA), Visual Java ++ (VJ++), C++ Builder. However, not all such classes are COM classes.

In VB, class modules that are part of an ActiveX DLL or ActiveX EXE are COM classes. In Visual C++ COM classes can be created using the ATL object wizard, or a class can be manually defined to conform to the rules of COM.

Most modern object oriented development environments allow you to create COM classes and implement interfaces. However, different development environments have different capabilities; these differences may affect the environments you can use to implement your custom objects.

Even VBA classes are actually COM classes; however such classes are not publicly creatable (VBA is a scripting environment; code cannot be compiled, and components cannot be accessed by other processes), making VBA generally unsuitable for the creation of custom components.

It is also possible to create classes in Visual Basic .NET (VB.Net) and Visual C# .NET (C#), which can act as COM classes via the .NET-COM interop bridge. For more information on creating custom classes using .NET, see the .NET section of the ArcGIS Developer Help (in the Development Environments section), where you can find walkthroughs for creating custom Command and DockableWindow classes in VB.NET and C#.

Class inheritance (aggregation)

Class inheritance is an object-oriented technique for customizing or extending existing classes. It is sometimes known as implementation inheritance or aggregation. When one class aggregates another, this class then exposes all the interfaces and members available on the aggregated class.

One benefit of aggregation is that you can pass an instance of the new class to clients that are expecting the original, aggregated class. In this way, you can add functionality, without needing to know all the inner workings of the aggregated class. Some of the examples described in the 'Extending the editor' section of this book demonstrate the use of this technique.

VB does not support aggregation, and is therefore excluded from your choice of development environment in these cases; VC++ does support aggregation. Aggregation is used to develop custom features in the 'Customizing the geodatabase' section of this book.

Interface implementation

COM classes communicate through interfaces, regardless of the underlying coclass. By implementing the interfaces that the framework is expecting to find, existing ArcObjects components interact with your custom components without being aware that the components are not part of ArcGIS.

All COM-compliant environments support interface implementation in some way. However, not all environments support all the features possible in IDL; therefore, different environments will have different abilities to implement particular interfaces.

Both the COM conventions and the IDL specification were based on the C language; therefore, C-based languages naturally support the widest range of IDL features. If you are developing with Visual C++ 6.0, you will be able to implement all the interfaces ArcObjects exposes, as you are using the same environment and compiler with which they were created. Other C-based environments may have slightly different capabilities.

If you are developing with Visual Basic, you will be able to implement the vast majority of the interfaces in ArcObjects. It is easy to quickly check if you can implement an interface—add a reference to the appropriate DLL, and add the Implements line to the code window.

If the interface name does not appear in the wizard bar's left pulldown list, you may have a problem—above you can see that ISymbol can be implemented in VB, but ISimpleLineSymbol cannot. Note that syntax errors in the code window may prevent the wizard bar from working correctly—you may want to check for syntax errors first before assuming the interface cannot be implemented in VB.

Using the wizard bar, you can easily check if an interface is implementable in VB.

For some interfaces that cannot be implemented in VB, ArcObjects includes VB-friendly equivalents. For example, the IPropertyPage interface definition contains the SetObjects method, which has a parameter of unsigned integer data type. The VB environment has no equivalent for an unsigned integer, and therefore IPropertyPage cannot be implemented in VB. In this particular case, ArcObjects provides the VB-friendly IComPropertyPage interface to do the same job as IPropertyPage, allowing the VB developer to implement a property page.

If you want to know more about exactly what makes an interface implementable or not in VB, see the 'Creating type libraries using IDL' topic in this section.


Visual Basic 6 editions

If you are planning to develop with VB, it is worth noting that this product is available as three different editions: Enterprise, Professional, or Learning editions.

All of these editions contain the same VB functionality and editor and may be used to create COM classes; therefore, they are suitable for creating classes for ArcGIS. However, each edition has different tools and utilities. It is recommended that you use the Professional or Enterprise version. Note that if you intend to use the Visual Modeler tool, you require the Enterprise version.


Topics relevant to particular environments

This book is focused on the design of solutions to particular programming problems, not on one particular development environment or another. Although many issues are dealt with differently by different environments, it is often the case that your general understanding of the issue is helped by understanding more than one environment-specific view.

In some cases where an interface cannot be implemented in VB, ArcObjects provides an alternative interface.

For this reason, programming issues discussed in this book are taken in turn, with reference to particular environments where appropriate. You should therefore review an entire topic, regardless of the environment you are using.

If you are developing in VB, you should find that you learn more about the background of an issue and the things that are hidden by the VB compiler.

If you are developing in VC++, you should find that this helps you to design components which can be used more effectively in other development environments, for example, VB or scripting environments.