Flylib.com

Books Software

 
 
 

Solutions


Solutions

These programming issues have perplexed developers for a number of years , and several techniques have already been developed to address them. For example:

  • Representation standards, such as eXternal Data Representation (XDR) and Network Data Representation (NDR), address the issue of passing data types between different machines. These standards compensate for issues such as big/little endian and different word sizes.

  • Language standards, such as ANSI C, allow the distribution of source code across compilers and machines. They permit source code to be recompiled on different machines and with different libraries without the need to modify the source files.

  • Architecture standards, such as the Distributed Computing Environment's (DCE) Remote Procedure Call (RPC), OMG's CORBA, and Microsoft's (Distributed) Component Object Model (COM/DCOM), address the issue of calling methods across language, process, and machine boundaries.

  • Execution environments, such as those provided by SmallTalk's and Java's Virtual Machines (VMs), allow code to execute on different physical machines by providing a standardized execution environment.

All of these approaches provide significant benefits to the application developer, but unfortunately none has solved ”or even attempted to address ”all the problems associated with a distributed computing environment. In particular, the issue of language interoperability deserves more attention. Language interoperability entails more than just a standardized calling model, such as those provided by COM and CORBA; it also involves a schema that allows classes and objects in one language to be used as first-class citizens in another language. Achieving this level of interoperability is a major goal of Microsoft's .NET Framework.


Comparing the .NET Framework and IDL-Based Systems

It is an interesting exercise to compare the architecture of the .NET Framework with other distributed architectures that provide many of the same facilities. Both COM and CORBA, for example, address many of the same issues that the .NET Framework tackles. These architectures utilize an Interface Definition Language (IDL), which addresses many of the issues discussed earlier. But how does this interaction happen?

When developing a program with either COM or CORBA, a developer writes an IDL file that represents the interfaces provided or required by the server. The IDL provides the common type system and some built-in types, and it also permits the developer to define his or her own simple types and interfaces. At IDL compile time, the IDL compiler can generate and write metadata to a file. Clients can use this file, which is known as a type library in COM and an interface repository in CORBA, to discover the types and the interfaces they provide. The IDL compiler also generates proxy objects. These objects, which reside in the client and server processes, translate data types between machine architectures and translate between the different execution models of different programming languages.

If COM and CORBA already address these issues, then why would a developer use the .NET Framework? First, both COM and CORBA have some limitations. An IDL is a separate language that must be used in addition to the development language. Although both COM's and CORBA's IDLs are based on C/C++, this fact offers little help to a SmallTalk programmer. Second, the IDLs greatly restrict facilities such as method overloading, and neither provides a rich exception hierarchy.

Third, the metadata files produced by the IDL compilers are not necessarily embedded with the type's definition. This fact leads to any of the following situations:

  • A developer may have access to a type (that is, its implementation file), but no metadata (that is, its type library or interface repository entries).

  • A developer may have a type's metadata but not the type (the reverse of the previous case).

  • A developer may have a type and inconsistent metadata ”in other words, the metadata refers to a different version of the type. This situation occurs because an IDL compiler generates the metadata but a language compiler generates the type.

Finally, IDLs deal in interfaces, not types ”hence their name . A developer could potentially find an interface that describes a number of methods that perform tasks that the developer wishes to provide and gain access to a type that implements this interface. The developer may then wish to add a single method to this interface. Unfortunately, he or she may not be able to reuse the type that implements the first interface and just add the implementation for the new method. In the .NET Framework, if a developer finds a type that implements all the methods required, he or she can subtype from that type, subject to certain constraints. The developer can then add, or even override, only those methods for which different behavior is required, regardless of the language in which either type is written.