maybe - or better probably
- i'm just to stupid to get it, but what are the advantages of interfaces?
Please look at Java's container and iterator interfaces and you get an idea of the advantages.
The classes implementing a certain interface don't need to inherit from the same class, and the code using the interface can easily switch to another implementation.
You can find much information about this topic and I will not repeat it here ...
However, my personal experience is that interfaces are overrated. Yes!
You can do the same things, and more, with abstract base classes.
In reality the code using the interfaced code often needs to access data behind the interface. However only methods can be defined for interface, not data.
For this reason the interfaces often have Get... and Set... methods just for the data access, and the implementing classes must define the data variables separately.
It is ok, but an abstract base class could do the same thing more easily. You can define variables in abstract classes.
Only if you implement many interfaces by one class, then the abstract base class approach does not work.
Interface can then solve the same problem that multiply inheritance does but without its negative side-effects.
So, using interfaces can lead to elegant design like Java's (container etc.) classes prove, but it requires more careful thinking across the whole library.
Partly it is a design decision. You can make an elegant design also by using abstract base classes.
For example the biggest Object Pascal app I know, Lazarus, uses lots of those base classes. I don't see how it would improve by using interfaces.
Object Pascal does not have a culture of using interfaces much.
It is mainly because the language has a serious design flaw: interfaces and memory management are mixed together!
This was a decision made by Borland a long time ago and was needed for Windows COM programming.
Support for reference counted objects is nice but binding it automatically to interfaces is a big mess and source of confusion. FPC has implemented another interface type which is not connected to memory management. Most people don't know it, I don't remember the exact syntax either now.
Regards,
Juha
P.S.
I don't like some other aspects of Java's libraries but IMO Java's container classes and their interfaces shine.