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

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

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

#1 User is offline   svHFCs 

  • New Member
  • Pip
  • Group: Members
  • Posts: 8
  • Joined: 09-August 14

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); }
}

0

#2 User is offline   svHFCs 

  • New Member
  • Pip
  • Group: Members
  • Posts: 8
  • Joined: 09-August 14

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!

This post has been edited by svHFCs: 30 August 2014 - 10:24 AM

0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users