Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Ok. Next question. I know (fro 2

Status
Not open for further replies.

SBerthold

Programmer
Sep 20, 2002
1,014
DE

Ok. Next question.

I know (from reading) about using a class interface and IMPLEMENTS, pretty much how it is used(created that is).

But, what is it really for? I mean, some where the implementing of the Implements logic is missing for me.
Why wouldn't I just declare a variable as Object, and depending on a condition, assign the business logic class, which, in each different class, has the same methods as an interface, to the variable.
Such as with a PayIncrease method for different classes (clsStaff, clsManagement,etc.). If I have to list in each class all of the methods of the PayIncrease interface anyways, why use the interface?
Or have I missed something?
 
I think the idea of interface is a kind of half-way feature towards abstract classes. If you have an object that must have certain methods in it then by using the interface you are makng sure that the programmer has to take this into account. I'm told that it's much better in .NET in that there is proper support for abstract classes
 
Implements is actually a half way feature towards Inheritance, something that all OO languages have had except for VB. Inheritance should inherite all code and variables from the object that it is derived from. Unfortunatly with VB, although you can inherite the interface, you do not inherit the code and this must be written for each object that inherits the interface.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top