The later maybe true (well, as far as *my* dealings with Microsoft go)
but the former is not.
I've never used Interface and never will.
You have missed a lot, then. There are a lot easier to understand if you
regard an interface as a behaviour. So the ICloneable interface means
that an object can be cloned, the ISerializable interface means that it
can be serialised. They say nothing about the implementation and so say
nothing about the class (type) but they say a lot about the what the
implementation does.
Consider this hyperthetical case:
interface IPrintable
{
void Render(PrinterContext ctx);
PaperType PerferredTypeOfPaper{get;}
event PrintedDelegate ItemPrinted;
}
Any class could implement this: Book, Photo, Page, Ticket. The point is
that if a class implements this interface it means it has the
respensibility to render itself to some printer context (say, a
container for a raster image), it has the responsibility to specify the
type of data it prefers to be printed on, and it can be notified that
the printing has completed. The class can do anything else it wants to
do, but it must do all of these things. The user of the interface is
only concerned with the interface's behaviour, it does not care about
anything else the object will do.
Imagine a printer object:
class Printer
{
public PrintItem(IPrintable doc);
}
This does not need to know about the type of the object passed, only
that it has the required behaviour. This gives you polymorphic code
because *any* object that implements IPrintable can be passed to
PrintItem. This is a *huge* advantage and your code will benefit
immensely from using interfaces.
But now I have to make major modifications to a large system where
almost all classes are based on some kind of Interface. Hundreds of
classes.
If the interfaces are factored correctly then this is great. IIRC the
maximum number of items in an interface is approximately five, if you
have more than that then you know that the interface was not correctly
factored and contains more than one behaviour.
When I want do add a new property or method I have to modify the
interface and next I have to modify dozens of other classes or create
new inteface.
Argh!!!!! NO NO NO!!!
This is not the way to do things. You should *only* add items to an
interface that are related to the behaviour. If the items represent
another behaviour then they should be in another interface (or possibly,
not in any at all). If the software you have is designed to have
interfaces with huge numbers of properties/methods then it is a poor
application and needs rewriting totally.
Sooner or later I will finish having a single class based on its own
interface. So what is the point of using Interface?
Madness.
If the application simply has an interface per class then there is no
point in using interfaces. The original developer should be made to
stand waist deep in sewage for soiling the good name of interfaces.
(Oh BTW, some of Microsoft's interfaces are designed very badly, and I
recommend the sewage treatment for those developers too.)
Richard