Free Advertising - Articles - Shares - Property Search - Loans

PDA

View Full Version : Aren't interfaces useless?


elixir
Nov 30th 2005, 3:06 am
I tried, I really tried to find a meaning to interfaces, but I just can't =/

As with many things in OOP, interfaces are really only supposed to have a semantical meaning, like encapsulation with public, private and protected is pretty much purely semantical. Making all of your variables public, for example, won't change anything in the compiled program, but instead make it easier to shoot yourself in the foot during coding and compilation.

It seems to me, that this concept of a "contract" between the interface and the class to implement certain functions is useless, as your program will never compile if it ever calls non-existant functions, anyway. What is the point of implementing interfaces, besides communicating (to a the programmer using the classes) that this class is sure to have that&that functions? He'll know anyway, won't he?