Top
NetCOBOL V11.0 Getting Started with COM Components
FUJITSU Software

3.5 Early Binding vs. Late Binding

As noted previously, the TESTFILEIO5 program has been modified to use Late Binding. We could have made the TESTFILEIO5 program use Early Binding instead making two changes to the program:

  1. The Class reference statement in the Repository would be changed to:

     Class FILEIO5 As “*COM:FILEIO5:FILEIO5”.
  2. The first invoke statement that currently calls the “CREATE-OBJECT” method would be changed to:

     Invoke FILEIO5 “NEW” Returning FILEIO-PTR.

Early Binding requires class definitions specified in the REPOSITIORY section to be written in the format:

 "*COM:com-server-name:class-name"

The com-server-name can be any name, but the class-name must be found in the associated type library, which is required for early binding. The com-server-name can be freely assigned by the user, but must be associated with the location of the type library and stored in the option file.

But what exactly is Early Binding vs. Late Binding? Binding defines the mode in which the client checks a method or interface of a COM server to determine interface specifics such as parameter types. This check must be done to ensure that the client is calling a valid method of the COM Server and that it is passing the correct number of properly defined parameters.

This check can take place at build time (similar in nature to a Linkage Editor resolving external references), or it can be done at dynamically at runtime. Performing this check at build time is known as Early Binding. Performing this check dynamically at runtime is known as Late Binding.

Late Binding has a slight performance penalty because additional work is required at runtime, but it has the benefit of allowing you to change COM Server .DLLs and rebuild them without being forced to rebuild the COM clients that access them.

Early Binding has the benefit of a slight performance gain because this work is done at build time and not required at runtime. It also has the benefit of finding interface errors at build time as opposed having to wait to find these types of errors at runtime.

Early binding does require the existence of a type library for any COM Server you wish to call, whereas Late Binding does not have this requirement.

Unless you are in need of every bit of performance you can obtain, Late Binding is typically a better option - especially when doing development as modules change often.

You should now have a basic understanding of how to create both COM Client and COM Server applications using NetCOBOL.

In the next chapters we will look at invoking the FILEIO5 COM server module from both Visual Basic and from an Internet application using an ASP page.