This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I guess I am having difficulty understanding the �why� of interfaces and I would really appreciate someone helping to clear this up for me. I understand that interfaces can inherit from other interfaces and that classes can implement multiple interfaces and I understand that this is a key difference between interfaces and inherited classes. What I don�t get is why you actually use interfaces and this is where I�m coming from. Interfaces contain no code bodies and all the methods for an interface must be implemented in the class. This confuses me because I don�t understand why the interface is used if the class has to write the implementation for all of the methods. Obviously I am missing something that is really profound; please help me to understand why the interface is used instead of just writing the members needed with no reference to an interface.
The answers to "why use interfaces" or "why use polymorphism" will take you into all the coolest OO theory. If you're writing two or three classes to satisfy an assignment you might not run into a need. But in architecting larger systems you can add major goodness with some advanced techniques. Drop down to the OO, UML and other cool stuff forum for that kind of talk.
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi