This is a mirror of official site: http://jasper-net.blogspot.com/

Late Binding - Myths and Reality

| Sunday, October 24, 2010
The concepts of late and early binding can be confusing, mainly because they aren’t really as different as they might first seem.
There is also a general belief that late binding in C# is sophisticated but hard work and in VB .NET less sophisticated but much easier.
There is a sense in which late binding is really isn’t any different from early binding – you could say it’s more a state of mind of the programmer, but it’s high time to look in more detail at how it all works.

What is late about late binding?

When you work with a strongly typed language then early binding is the norm – indeed it might even be the only type of binding allowed.
The basic idea is that you declare the type of every variable you use within the code and this allows the compiler to check what you are writing for correctness. It can also allow the IDE to provide help by listing the methods and properties that you can use as in the Intellisense feature of Visual Studio.
Where early binding starts to show its limitations is when you need to write some code that deals with a range of data types. If at this point you are thinking “generics” then yes but it’s still, in concept, early bound. If you express an algorithm as generic code all that happens is that early binding is deferred until you specify, at design time, the types to be used with the template.
Late binding implies that the type of an object isn’t known until run time and this goes beyond generic templates. It is useful to change from thinking about variables or instantiated classes to “pointers” or more properly references to instances.
The idea is that you have a pointer or reference to an instance of an unknown type – unknown that is at design time. To make use of the unknown type you have to discover its type at run time using some sort of dynamic type information.

Read more: I Programmer

Posted via email from .NET Info

0 comments: