For the past few hours I have been pouring through hundreds of internet articles, blogs and posts in various forums regarding interfaces.
I get a general idea that it is basically a class with no implementation at all...a "skeleton" if you will.
I was hoping for an a-ha! moment that never came. This is my last ditch effort here.
What exactly is the usefulness of making interfaces?
I've read that it makes code more clean and easier to manage, but I fail to see how it would ever do that. Changing a public class that is used by many other methods or classes seems to be much MUCH more manageable than editing a "template" and then having to edit (maybe) every single instance of that template.
Also, it provides no information on it's function.
I mean an interface like this:
public interface ICopy
{
public void CopyMethod();
}
Could be implemented in any way a programmer wants like this:
public class FileManipulation : ICopy
{
public void CopyMethod()
{
//code to copy files
}
}
but it could also be implemented like this:
public class MakePrankCalls : ICopy
{
public void CopyMethod()
{
//code to use a modem and dial random numbers then play a .wav file to prank them
}
}
I mean it basically means nothing right?
The definition of an interface (in computer science) is "a point of interaction between two components." I fail to see how an interface in C# achieves this at all...
It seems to me that if I look at source code from someone that uses interfaces, I cannot rely on the fact that simply because an interface is used on a class, that it was used correctly (like my sample above) right?
I'm really hoping that someone can set me straight here and say something like "no, no, no! your missing the fact that __________________."
Anyone?