Understanding: Interfaces

I, on the other hand, prefer to say: Interfaces can be best explained as a 'language'; like English or Arabic. Sometimes classes need to communicate between each other, if written by the same person, that would not be much of a problem. But sometimes these classes are written by a number of different people, probably people from another firm, country and/or continent.

In order to communicate with each other, like us humans (at least those of us who call themselves that :-)) classes need a common language they all speak. This language must be understood by all and follow the same rules and regulations everywhere.

In programming this is called an interface. It is a way of ensuring all related classes speak the same language. For example, if class A wants class B to do a certain task, the only way for class A to insure that class B can do the task, is by checking if class B implements the ICanDoTask (for example) interface.

Unlike inheritance, a class can implement an unlimited number of interfaces.

Perhaps you can understand more if you read this: http://www.vbip.com/books/1861004915/chapter_4915_10.asp.

Enjoy!

Bashar Lulu
MVP - Visual Basic
INETA Country Leader - Gulf
Read my blog: http://basharlulu.blogspot.com
My website: www.basharlulu.net
My developer framework: www.jclframework.net

Ebook Download
View all
Learn
View all