[AccessD] more on early versus late binding

Bob Hall rjhjr at cox.net
Tue Jul 13 02:27:28 CDT 2004


On Mon, Jul 12, 2004 at 09:39:20PM -0400, jwcolby wrote:
> >The line
>      lngWibble = ReadSomeFileAndFetchWibbleValue()
> is late binding. The variable isn't bound to the specific value until the
> code is run. 
> 
> 
> Not exactly true.  If 

My example comes from a book published by Microsoft call "Code Complete".
 
> In fact early and late binding don't really apply to built in data types
> such as strings and numbers (in VB at any rate) since these are not objects.

It doesn't matter whether we're talking about primitive data types or user defined classes. Strings, numbers, and objects are all instances of of types (classes). The only difference between a primitive type and a user defined class is the "user defined". When you declare a String or Integer variable, you actually are declaring an object that gets it's operations and properties from its type. The extra work involved in declaring a VBA object is due to the fact that it isn't an instance of a primitive type. Since it's not built in to the language, you have to do extra work to tell VBA what it is.

> Objects are typically classes or OCXs etc which have methods and properties.

Both classes and primitive data types have operations and properties. The fact that class operations are called methods and are called using a different syntax doesn't change the fact that they are the same thing. You obviously can't have primitive types inheriting procedures from other types; it wouldn't have any point. But type operators are overloaded; the "+" operator does one thing with numbers and another with strings. And integer multiplication is not the same as floating point mulitiplication. So where it is relevant, primitive and non-primitive types act the same way.

Early and late binding can be used in purely non-OOP languages. A definition: 
"early binding:
    A characteristic of programming languages that perform most bindings during translation, usually to achieve execution efficiency. For example, COBOL, Fortran, Pascal."

And a binding doesn't have to involve an object. An example of early binding from Java:
     int wibble = 47;

I've seen early and late binding discussed in terms of variable names, function names, and object names.



More information about the AccessD mailing list