GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  Microsoft  >  C#
Go To First  |  Previous Question  |  Next Question 
 C#  |  Question 385 of 436    Print  
What is late binding and early binding? What is the benefits and disadvantages of using them?

  
Total Answers and Comments: 1 Last Update: December 03, 2007     Asked by: BostonCow 
  
 Sponsored Links

 
 Best Rated Answer
Submitted by: SoCalBruce
 

Binding refers the object type definition. You are using Early Binding if the object type is specified when declaring your object. Eg if you say Dim myObject as ADODB.Recordset that is early binding (VB example).

If on the other hand you declare your object as a generic type you are late binding. Eg if you Dim myObject as Object (VB example).

One should note that binding is determined at object declaration and not at object instantiation. Therefore it does not matter if you later go on to Set myObject = New ADODB.Recordset or Set myObject = CreateObject(”ADODB.Recordset”).

Early binding allows developers to interact with the object’s properties and methods during coding. You can enjoy the benefits of intellisense. Also, early binding permits the compiler to check your code. Errors are caught at compile time. Early binding also results in faster code. It’s disadvantage is that you cannot create a generic object which may be bound to different types of objects.


Late binding on the other hand permits defining generic objects which may be bound to different objects. Eg you could declare myControl as Control without knowing which control you will encounter. You could then query the Controls collection and determine which control you are working on using the TypeOf method and branch to the section of your code that provides for that type. This is the only benefit of late binding. It’s disadvantages are that it is error prone and you will not enjoy much intellisense whilst coding.




Above answer was rated as good by the following members:
Loki117
December 03, 2007 13:33:10   #1  
SoCalBruce Member Since: December 2007   Contribution: 2    

RE: What is late binding and early binding? What is the benefits and disadvantages of using them?

Binding refers the object type definition. You are using Early Binding if the object type is specified when declaring your object. Eg if you say Dim myObject as ADODB.Recordset that is early binding (VB example).

If on the other hand you declare your object as a generic type you are late binding. Eg if you Dim myObject as Object (VB example).

One should note that binding is determined at object declaration and not at object instantiation. Therefore it does not matter if you later go on to Set myObject New ADODB.Recordset or Set myObject CreateObject(”ADODB.Recordset”).

Early binding allows developers to interact with the object’s properties and methods during coding. You can enjoy the benefits of intellisense. Also early binding permits the compiler to check your code. Errors are caught at compile time. Early binding also results in faster code. It’s disadvantage is that you cannot create a generic object which may be bound to different types of objects.


Late binding on the other hand permits defining generic objects which may be bound to different objects. Eg you could declare myControl as Control without knowing which control you will encounter. You could then query the Controls collection and determine which control you are working on using the TypeOf method and branch to the section of your code that provides for that type. This is the only benefit of late binding. It’s disadvantages are that it is error prone and you will not enjoy much intellisense whilst coding.



 
Is this answer useful? Yes | NoAnswer is useful 1   Answer is not useful 0Overall Rating: +1    

 Related Questions

SQLServer.NET data provider is high-speed and robust, but requires SQL Server license purchased from Microsoft. OLE-DB.NET is universal for accessing other sources, like Oracle, DB2, Microsoft Access 
Latest Answer : Ans:Advantage:SQLServer.NET data provider is high-speed and robust.DisAdvantage.but requires SQL Server license purchased from Microsoft ...

.NET FRAMEWORK1. What is .NET Framework?The .NET Framework has two main components: the common language runtime and the .NET Framework class library.You can think of the runtime as an agent that manages 
Latest Answer : The .NET framework is a platform over which multiple languages are running.The 2 main components are 1. FRAMEWORK CLASS LIBRARY2. COMMON LANGUAGE RUNTIMEIt's features like CTS provide Cross Language Interoprabality.The CLR is the main Governing body ...
Read Answers (1) | Asked by : Prasanna Muthukrishnan

Latest Answer : Objects are generally late bound when using class factories with interfaces (or base classes). An example of late binding can be seen below. The function that generates the concrete object (at runtime) will decide which type of concrete object to instantiateIReader ...

Latest Answer : Boxing is converting a value-type to reference type. An example is converting an integer value to an object value.Ex:   int intValue = 10;   object obj = (object)intValue;This is used if you want to pass variables of object types ...
Read Answers (1) | Asked by : BostonCow

Latest Answer : Binding refers the object type definition. You are using Early Binding if the object type is specified when declaring your object. Eg if you say Dim myObject as ADODB.Recordset that is early binding (VB example). If on the other hand you declare ...
Read Answers (1) | Asked by : BostonCow


 Sponsored Links

 
Related Articles

SQA Costs and Benefits

SQA Costs and Benefits Software Quality Assurance has been developed for years and it has been proven to be useful for some situations We have to emphasize the word some” since there are companies who have disputed the idea of SQA with so many reasons mosgoogle Taking a look at the reaso
 

EDI Benefits

EDI Benefits Within various industries EDI has been used to great advantages and many benefits have been expounded in its regard EDI´ s benefits relate to environmental impact improved time efficiency improved accuracy and increased flexibility enhanced partnership labor costs shipping EDI
 

SOA Disadvantages

SOA Disadvantages Service Oriented Architecture Disadvantages Applicability Service Oriented Architecture may not always be the best architectural choice because optimal utilization of SOA requires additional development and design attempts as well as infrastructure which translates into costs esc
 

Benefits of ERP for the Financial Area

Benefits of ERP for the Financial Area At this time the main motivation of some companies for choosing ERP is to achieve an improvement in the management of their financial area Sometimes they rush into the decision without taking into consideration the real contribution of the implementation in rel
 

The Interview Snafu

How to turn someone else’s mistake to your advantage Your dream job is about to become reality. A recruiter gave you the heads up about the perfect position at Humungous Conglomerate, Inc. You went through five interviews as well as a battery of psychological tests mandated by their HR de
 

Winning a Job Interview with a Winning Resume

Does your resume unlock your potential, take your skills to the highest level and win you the interview and the job you want now? The job market today is highly competitive and even if you think you have what it takes to get an interview you won’t get over the line without a polished, prof
 

XML Disadvantages

XML Disadvantages The extensive markup language is the way to go for developing future web applications and it almost defines the future of web development There are no doubts about its performance in this arena However XML also has some draw backs which need to be looked at and improved upon The re
 

NLP Persuasion Patterns and Benefits

NLP Persuasion Patterns and Benefits Persuasion is an art mastered by only a select few Most often than not people engage in conversations that lack tact skill and wit In this modern age it has become highly essential to persuade and influence people in business or in personal life mosgoogle center
 

Importance of Proper English during Job Interview

Importance of Proper English during Job Interview Your job interview is crucially important and it will determine whether or not you will get the job Depending on the type of job you re going for it is very important for you to use proper English In most cases jobs which offer higher salaries will h
 

Importance of Vocabulary from an Early Age

Importance of Vocabulary from an Early Age Why Vocabulary is an Important Part of Literacy It can be said that vocabulary is comprised of three things and these are writing reading and speaking All three of these elements are used to make up a larger structure that is called literacy While literacy
 

About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape