Wednesday, February 09, 2005

Interfaces Under the Hood !!

here is one my faourite topic "Interfaces".I have to be sincere guys when i started my programming career in 1999 as a postgraduate in CS.Little i knew about computers leave those interfaces for god sake :)).

my first exposure to interfaces was when i started to work on .net, before .Net i had worked with C, C++ and Visual Basic but i had not cared to know much about the interfaces. But in .Net i cann't escape and i was kind of a guy who wants to go to bottom of things :). so bear with me friends, i will tell u the story of my journey to know all about interfaces. i am sure it will be helpful to some of you out there and also give me your feedback so that i may correct my mistakes.

But before starting the discussion on interfaces on its myths and realities. let me share some of questions usually interviewers ask (god knows if they really know the correct answer themselves) and also some of the popular answers they get!! and myself have got when i interviewed some of those so called experinced guys and gals :).

well lets start

1. what is an interface ?
2. why we need interfaces ?
3. what is an abstract class ?
4. when we need pure abstract classes ?
5. people say java supports multiple inheritance through interfaces ???? can you explain me a bit ?
6. when we can implement the same functionality using pure abstract classes what was the need for interfaces ?
7. Justify the case for interfaces ??
well these are just a set of questions to get started and i have heard lots of funny and absurd answers for these !! well give me your thoughts on these and i will share some of those answers i have heard and seen and try to clarify the real internals of Interfaces.



5 Comments:

At February 9, 2005 at 3:57 PM, Blogger pbsk said...

This comment has been removed by a blog administrator.

 
At February 9, 2005 at 3:58 PM, Blogger pbsk said...

post your comments and feedback !!

 
At February 9, 2005 at 4:19 PM, Blogger bp said...

1. what is an interface ?
A definition point for the purpose of integration between heterogeneous environments. Well, i know thats not a too 'techincal' answer when u think in terms of memory management etc., but, its sure tells the purpose. as i remember, interfaces are slow compared to abstract class because they need an extra indirection pointer to find the corresponding method in the actual class. i also remember about readign some stuff related to global heap pointer, which works with placement new operator in c++. (well, this concept of placement new operator itself is a superb concept to discuss. plz blog this also later).but, forgot now. this should be a serious consideration in huge applications where memory consumption is a major factor.


2. why we need interfaces ?
plz see the above answer.


3. what is an abstract class ?
functionally almost similar to interfaces, except that they are capable of providing a default implementation,
protected access specifier, static methods etc.,


4. when we need pure abstract classes ?
well, that is an interface in terms of java.


5. people say java supports multiple inheritance through interfaces ???? can you explain me a bit ?
other than the capability of default implementation, i dont find much difference between interfaces/abstract
classes(excluding the memory management part). so, without any implementation strategy, if more than one definition point is being brought into reality, then it doesnt matter whether its abstract class or interface.



6. when we can implement the same functionality using pure abstract classes what was the need for interfaces ?
--no comments--


7. Justify the case for interfaces ??
--no comments--

 
At February 9, 2005 at 4:33 PM, Anonymous Anonymous said...

"A definition point for the purpose of integration between heterogeneous environments"

I like that sentence !!

 
At April 8, 2005 at 2:56 PM, Anonymous Anonymous said...

What is Virtual functions in vb.net and in CSharp? is it like Abstract Menthods(MustOverride)?

 

Post a Comment

<< Home