• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Please help me to understand interfaces

 
t andrews
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic