Jump to content


Photo

Ch 7: Still Don't Understand The Benefit Of Creating/using An Interface


  • Please log in to reply
1 reply to this topic

#1 svHFCs

svHFCs

    New Member

  • Members
  • Pip
  • 8 posts

Posted 30 August 2014 - 05:03 AM

I'm sure I'm just missing the benefit, but I'm not seeing it.

What is the point of creating an interface with methods and properties if I can't define their parameters and include functionality and just call that method or property and pass through to the interface? I'm basically just redundantly writing the methods and propeties twice.Why not just create the functions and properites in the class and forget the interface? Ok, understood, so what is the point?

The book states on page 297 "You don't write the code for the methods in the interface, just their names. You write the code in the class that implements it."

For example:

What is the point of this:

interface IMyInterface {
     
     void WriteText()
}

When I still have to do this:

class Writing : IMyInterface {

    public void Write ( string someText) {
          Console.WriteLine(someText); }
}


#2 svHFCs

svHFCs

    New Member

  • Members
  • Pip
  • 8 posts

Posted 30 August 2014 - 10:22 AM

Nevermind, I think I finally grasped it after reading pages 296 - 298 over and over and over....

Sorry, I need to be able to talk these out with someone. Usually after I post, 75% of the time it comes to me. Or someone responds to help the fruition happen faster.

Thanks again! Expect more questions from me!

Edited by svHFCs, 30 August 2014 - 10:24 AM.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users