Results 1 to 7 of 7

Thread: Interface in OOP

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Oct 2005
    Posts
    167

    Question Interface in OOP

    What is the advantages of using Interface in OOP? Please give an example using Interface to clarify that using Interface is better than one without interface.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Interface in OOP

    Implementing an interface offers advantages in certain circumstances. One advantage is that it allows you to take a number of different types, that may be quite different in some regards, and treat them in the same way. An example would be the DataGrid.DataSource property, which will accept any component that implements either the IList or IListSource interface. This means that you can create a class with whatever functionality you like but as long as it implements one of those interfaces you can bind it to a DataGrid.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Interface in OOP

    An interface provides a common (if perhaps partial) specifiction for a class. You can rely on the fact that all classes that implement that interface will have the same methods as defined in the interface, even if they behave differently.

    Another example is plugins, if you design an common interface for an application plugin you can specify plugins using that interface, regardless of what the plugin actually does.

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Oct 2005
    Posts
    167

    Re: Interface in OOP

    I want to ge more ideas about Interface. Need help.

  5. #5
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Interface in OOP

    Interface
    Interface (Computer Science) - this is probably what you're looking for
    User Interface

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Interface in OOP

    Read this and follow the relevant links at the bottom, which really gives you all you need to know about interfaces as they relate to VB.NET: http://msdn.microsoft.com/library/de...BSpec6_7_1.asp

    Things are pretty much the same in C#.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  7. #7
    Banned
    Join Date
    Nov 2005
    Posts
    2,367

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width