locked
Interface RRS feed

  • Question

  • Hi

    What is an interface and what is its need? I have read on it but am not sure on the scope of its need.

    Thanks

    Regards

    Friday, January 15, 2016 10:41 PM

Answers

  • Yahya,

    To sum up, an interface is a code contract - which is why it can be used as a type by itself.

    Knowing that the "terms of use" are that the class which implements that interface has to implement all of the properties, methods, and events in an interface, you can rely on them being there.

    An obvious one is IDisposable which you'll see somewhat frequently.

    If a class implements IDisposable, you can be sure that there's a public .Dispose method.


    If I had eight hours to chop down a tree, I'd spend six sharpening my axe. -- Abraham Lincoln

    Saturday, January 16, 2016 1:23 AM
  • An interface is a set of methods that classes that implement the interface must include. The interface doesn't include any code for those methods, just the method declarations.

    A class might implement several different interfaces, and users of that class know that they can use any of the methods included in those interfaces. One useful feature is that you can write a method that takes an argument whose type is an interface, and the method can be called using any object that implements that interface. For example, the following method takes an argument that can be any object that implements IEnumerable(Of Integer).

    Sub DoSomething(items As IEnumerable(Of Integer))
        For Each item As Integer in items
            'Do something with item
        Next
    End Sub

    You could call it to process an List(Of Integer), or an Array of Integer, among others.

    Friday, January 15, 2016 10:56 PM
  • http://www.codeproject.com/Articles/642505/Advantage-of-using-Interface-and-Inheritance-in-VB

    If you are doing Object Oriented Programming you will see Interfaces come into play in design patterns.

    https://www.safaribooksonline.com/library/view/visual-basic-design/0201702657/

    Here is a classic design pattern used in a Data Access Layer, another design pattern,  called a DAO Data Access Object pattern.

    https://en.wikipedia.org/wiki/Data_access_object

    Here you see the DAO pattern being implemented in the link.

    http://www.tutorialspoint.com/design_pattern/data_access_object_pattern.htm

    You see Interfaces used heavily in .NET solutions  that implement the programming principles explained in the link, which is highly sought out expertise in .NET developers that know it and how to use it.  

    http://www.codeproject.com/Articles/465173/Dependency-Inversion-Principle-IoC-Container-Depen

    Below you see the DAO pattern in action in the code below.

    See if you can implement Interface usage in the simple VB N-tier, another design pattern, solution by implementing Interfaces on the BLL and DAL classes.

    http://www.codeproject.com/Articles/21115/Building-an-N-Tier-Application-in-VB-NET-in-Step

    https://en.wikipedia.org/wiki/Multitier_architecture

    https://en.wikipedia.org/wiki/Separation_of_concerns

    What is being talked about is implemented in .NET enterprise level solutions all of the time.

    Imports Entities
    Imports System.Collections.Generic
    Public Interface IArticleDao
        Function GetArticle(id As Int32) As DTOArticle
        Function GetArticles() As List(Of DTOArticle)
        Sub UpdateArticles(articles As List(Of DTOArticle))
        Sub AddArticles(articles As List(Of DTOArticle))
        Sub DeleteArticle(article As DTOArticle)
    End Interface
    
    
    
    Imports System.Collections.Generic
    Imports Entities
    Imports System.Data.EntityClient
    
    Namespace DAL
        Public Class ArticleDao
            Implements IArticleDao
    
            Private Const pcdb As String = "name=PublishingCompanyEntities"
    
            Public Sub AddArticles(articles As List(Of Entities.DTOArticle)) Implements IArticleobj.AddArticles
    
                Dim conn = New EntityConnection(pcdb)
                Dim db = New PublishingCompanyEntities(conn)
    
                Using conn
                    Using db
                        Try
                            For Each article In articles
                                Dim artc = New Article With {.AuthorID = article.AuthorID, .Title = article.Title.Trim, .Body = article.Body.Trim}
                                db.AddToArticles(artc)
                                db.SaveChanges()
                            Next
    
                        Finally
                            conn.Close()
                        End Try
                    End Using
                End Using
    
            End Sub
    
            Public Sub DeleteArticle(article As Entities.DTOArticle) Implements IArticleobj.DeleteArticle
    
                Dim thearticle = New Article With {.ArticleID = article.ArticleID}
    
                Dim conn = New EntityConnection(pcdb)
                Dim db = New PublishingCompanyEntities(conn)
    
                Using conn
                    Using db
                        Try
    
                            db.AttachTo("Articles", thearticle)
                            db.DeleteObject(thearticle)
                            db.SaveChanges()
    
                        Finally
                            conn.Close()
                        End Try
                    End Using
                End Using
    
            End Sub
    
            Public Function GetArticle(id As Integer) As Entities.DTOArticle Implements IArticleobj.GetArticle
    
                Dim dto = New DTOArticle
                Dim conn = New EntityConnection(pcdb)
                Dim db = New PublishingCompanyEntities(conn)
    
                Using conn
                    Using db
                        Try
    
                            Dim thearticle = (From p In db.Articles
                                       Where p.ArticleID = id
                            Select p).FirstOrDefault()
    
                            If Not IsNothing(thearticle) Then
                                dto.ArticleID = thearticle.ArticleID
                                dto.AuthorID = thearticle.AuthorID
                                dto.Title = thearticle.Title.Trim
                                dto.Body = thearticle.Body.Trim
                            End If
    
                        Finally
                            conn.Close()
                        End Try
                    End Using
                End Using
    
                Return dto
    
            End Function
    
            Public Function GetArticles() As List(Of Entities.DTOArticle) Implements IArticleobj.GetArticles
    
                Dim dtos = New List(Of DTOArticle)
                Dim conn = New EntityConnection(pcdb)
                Dim db = New PublishingCompanyEntities(conn)
    
                Using conn
                    Using db
                        Try
                            Dim results = (From a In db.Articles Select a).ToList
    
                            dtos.AddRange(results.Select(Function(a) New DTOArticle With {.ArticleID = a.ArticleID,
                                                                                                                              .AuthorID = a.AuthorID,
                                                                                                                              .Title = a.Title.Trim,
                                                                                                                              .Body = a.Body.Trim}))
                        Finally
                            conn.Close()
                        End Try
                    End Using
                End Using
    
                Return dtos
    
            End Function
    
            Public Sub UpdateArticles(articles As List(Of Entities.DTOArticle)) Implements IArticleobj.UpdateArticles
    
                Dim conn = New EntityConnection(pcdb)
                Dim db = New PublishingCompanyEntities(conn)
    
                Using conn
                    Using db
                        Try
                            For Each art In articles
    
                                Dim thearticle = New Article() With {.ArticleID = art.ArticleID}
    
                                db.AttachTo("Articles", thearticle)
                                thearticle.AuthorID = art.AuthorID
                                thearticle.Title = art.Title.Trim
                                thearticle.Body = art.Body.Trim
    
                                db.SaveChanges()
    
                            Next
                        Finally
                            conn.Close()
                        End Try
                    End Using
                End Using
            End Sub
    
        End Class
    End Namespace
    

    Friday, January 15, 2016 11:55 PM
  • Hi

    What is an interface and what is its need? I have read on it but am not sure on the scope of its need.

    Thanks

    Regards

    Something that comes to mind is something that I worked on earlier this week. The following looks fairly meek and not very powerful, I think you'd agree:

        Public Interface IFileData
            ''' <summary>
            ''' Gets an IEnumerable(Of System.IO.FileInfo).
            ''' </summary>
            ''' <value></value>
            ''' <returns></returns>
            ''' <remarks></remarks>
            ReadOnly Property Files As IEnumerable(Of FileInfo)
        End Interface

    It's all that's needed though. Any class - including any class that you'd create - can now use the class that I created for this project (what it is and does doesn't matter) simply by passing in an instance of that interface.

    As an example, I created a class but it can be any class so long as it implements that one simple interface:

    Public Class FileData Implements IFileData Private _files As IEnumerable(Of FileInfo) Public Sub New(ByVal filePath As String) Try If String.IsNullOrWhiteSpace(filePath) Then Throw New ArgumentException("The file path cannot be null or empty.") Else Dim fi As New FileInfo(filePath) Dim list As New List(Of FileInfo) From {fi} _files = list.ToArray End If Catch ex As Exception Throw End Try End Sub Public Sub New(ByVal filePathList As List(Of String)) Try If filePathList Is Nothing Then Throw New _ ArgumentNullException("Collection Of File Paths", _ "Cannot be null." & vbCrLf) ElseIf filePathList.Count = 0 Then Throw New _ ArgumentOutOfRangeException("Collection Of File Paths", _ "Cannot be empty." & vbCrLf) Else Dim list As New List(Of FileInfo) For Each filePath As String In filePathList Dim fi As New FileInfo(filePath) list.Add(fi) Next _files = list.ToArray End If Catch ex As Exception Throw End Try End Sub Public ReadOnly Property Files As System.Collections.Generic.IEnumerable(Of System.IO.FileInfo) _ Implements IFileData.Files Get Return _files End Get End Property End Class


    So you could create your own class and implement IFileData and then pass in an instance of your class to something else that I've created and it would work just exactly the same.

    The class receiving it doesn't have to implement that interface (mine doesn't); it has no idea where the data came from nor does it need to... it needs to know only what IFileData instructs it to have - which in this case is just have a single read-only property.


    If I had eight hours to chop down a tree, I'd spend six sharpening my axe. -- Abraham Lincoln

    Saturday, January 16, 2016 1:40 AM

All replies

  • An interface is a set of methods that classes that implement the interface must include. The interface doesn't include any code for those methods, just the method declarations.

    A class might implement several different interfaces, and users of that class know that they can use any of the methods included in those interfaces. One useful feature is that you can write a method that takes an argument whose type is an interface, and the method can be called using any object that implements that interface. For example, the following method takes an argument that can be any object that implements IEnumerable(Of Integer).

    Sub DoSomething(items As IEnumerable(Of Integer))
        For Each item As Integer in items
            'Do something with item
        Next
    End Sub

    You could call it to process an List(Of Integer), or an Array of Integer, among others.

    Friday, January 15, 2016 10:56 PM
  • http://www.codeproject.com/Articles/642505/Advantage-of-using-Interface-and-Inheritance-in-VB

    If you are doing Object Oriented Programming you will see Interfaces come into play in design patterns.

    https://www.safaribooksonline.com/library/view/visual-basic-design/0201702657/

    Here is a classic design pattern used in a Data Access Layer, another design pattern,  called a DAO Data Access Object pattern.

    https://en.wikipedia.org/wiki/Data_access_object

    Here you see the DAO pattern being implemented in the link.

    http://www.tutorialspoint.com/design_pattern/data_access_object_pattern.htm

    You see Interfaces used heavily in .NET solutions  that implement the programming principles explained in the link, which is highly sought out expertise in .NET developers that know it and how to use it.  

    http://www.codeproject.com/Articles/465173/Dependency-Inversion-Principle-IoC-Container-Depen

    Below you see the DAO pattern in action in the code below.

    See if you can implement Interface usage in the simple VB N-tier, another design pattern, solution by implementing Interfaces on the BLL and DAL classes.

    http://www.codeproject.com/Articles/21115/Building-an-N-Tier-Application-in-VB-NET-in-Step

    https://en.wikipedia.org/wiki/Multitier_architecture

    https://en.wikipedia.org/wiki/Separation_of_concerns

    What is being talked about is implemented in .NET enterprise level solutions all of the time.

    Imports Entities
    Imports System.Collections.Generic
    Public Interface IArticleDao
        Function GetArticle(id As Int32) As DTOArticle
        Function GetArticles() As List(Of DTOArticle)
        Sub UpdateArticles(articles As List(Of DTOArticle))
        Sub AddArticles(articles As List(Of DTOArticle))
        Sub DeleteArticle(article As DTOArticle)
    End Interface
    
    
    
    Imports System.Collections.Generic
    Imports Entities
    Imports System.Data.EntityClient
    
    Namespace DAL
        Public Class ArticleDao
            Implements IArticleDao
    
            Private Const pcdb As String = "name=PublishingCompanyEntities"
    
            Public Sub AddArticles(articles As List(Of Entities.DTOArticle)) Implements IArticleobj.AddArticles
    
                Dim conn = New EntityConnection(pcdb)
                Dim db = New PublishingCompanyEntities(conn)
    
                Using conn
                    Using db
                        Try
                            For Each article In articles
                                Dim artc = New Article With {.AuthorID = article.AuthorID, .Title = article.Title.Trim, .Body = article.Body.Trim}
                                db.AddToArticles(artc)
                                db.SaveChanges()
                            Next
    
                        Finally
                            conn.Close()
                        End Try
                    End Using
                End Using
    
            End Sub
    
            Public Sub DeleteArticle(article As Entities.DTOArticle) Implements IArticleobj.DeleteArticle
    
                Dim thearticle = New Article With {.ArticleID = article.ArticleID}
    
                Dim conn = New EntityConnection(pcdb)
                Dim db = New PublishingCompanyEntities(conn)
    
                Using conn
                    Using db
                        Try
    
                            db.AttachTo("Articles", thearticle)
                            db.DeleteObject(thearticle)
                            db.SaveChanges()
    
                        Finally
                            conn.Close()
                        End Try
                    End Using
                End Using
    
            End Sub
    
            Public Function GetArticle(id As Integer) As Entities.DTOArticle Implements IArticleobj.GetArticle
    
                Dim dto = New DTOArticle
                Dim conn = New EntityConnection(pcdb)
                Dim db = New PublishingCompanyEntities(conn)
    
                Using conn
                    Using db
                        Try
    
                            Dim thearticle = (From p In db.Articles
                                       Where p.ArticleID = id
                            Select p).FirstOrDefault()
    
                            If Not IsNothing(thearticle) Then
                                dto.ArticleID = thearticle.ArticleID
                                dto.AuthorID = thearticle.AuthorID
                                dto.Title = thearticle.Title.Trim
                                dto.Body = thearticle.Body.Trim
                            End If
    
                        Finally
                            conn.Close()
                        End Try
                    End Using
                End Using
    
                Return dto
    
            End Function
    
            Public Function GetArticles() As List(Of Entities.DTOArticle) Implements IArticleobj.GetArticles
    
                Dim dtos = New List(Of DTOArticle)
                Dim conn = New EntityConnection(pcdb)
                Dim db = New PublishingCompanyEntities(conn)
    
                Using conn
                    Using db
                        Try
                            Dim results = (From a In db.Articles Select a).ToList
    
                            dtos.AddRange(results.Select(Function(a) New DTOArticle With {.ArticleID = a.ArticleID,
                                                                                                                              .AuthorID = a.AuthorID,
                                                                                                                              .Title = a.Title.Trim,
                                                                                                                              .Body = a.Body.Trim}))
                        Finally
                            conn.Close()
                        End Try
                    End Using
                End Using
    
                Return dtos
    
            End Function
    
            Public Sub UpdateArticles(articles As List(Of Entities.DTOArticle)) Implements IArticleobj.UpdateArticles
    
                Dim conn = New EntityConnection(pcdb)
                Dim db = New PublishingCompanyEntities(conn)
    
                Using conn
                    Using db
                        Try
                            For Each art In articles
    
                                Dim thearticle = New Article() With {.ArticleID = art.ArticleID}
    
                                db.AttachTo("Articles", thearticle)
                                thearticle.AuthorID = art.AuthorID
                                thearticle.Title = art.Title.Trim
                                thearticle.Body = art.Body.Trim
    
                                db.SaveChanges()
    
                            Next
                        Finally
                            conn.Close()
                        End Try
                    End Using
                End Using
            End Sub
    
        End Class
    End Namespace
    

    Friday, January 15, 2016 11:55 PM
  • Yahya,

    To sum up, an interface is a code contract - which is why it can be used as a type by itself.

    Knowing that the "terms of use" are that the class which implements that interface has to implement all of the properties, methods, and events in an interface, you can rely on them being there.

    An obvious one is IDisposable which you'll see somewhat frequently.

    If a class implements IDisposable, you can be sure that there's a public .Dispose method.


    If I had eight hours to chop down a tree, I'd spend six sharpening my axe. -- Abraham Lincoln

    Saturday, January 16, 2016 1:23 AM
  • Hi

    What is an interface and what is its need? I have read on it but am not sure on the scope of its need.

    Thanks

    Regards

    Something that comes to mind is something that I worked on earlier this week. The following looks fairly meek and not very powerful, I think you'd agree:

        Public Interface IFileData
            ''' <summary>
            ''' Gets an IEnumerable(Of System.IO.FileInfo).
            ''' </summary>
            ''' <value></value>
            ''' <returns></returns>
            ''' <remarks></remarks>
            ReadOnly Property Files As IEnumerable(Of FileInfo)
        End Interface

    It's all that's needed though. Any class - including any class that you'd create - can now use the class that I created for this project (what it is and does doesn't matter) simply by passing in an instance of that interface.

    As an example, I created a class but it can be any class so long as it implements that one simple interface:

    Public Class FileData Implements IFileData Private _files As IEnumerable(Of FileInfo) Public Sub New(ByVal filePath As String) Try If String.IsNullOrWhiteSpace(filePath) Then Throw New ArgumentException("The file path cannot be null or empty.") Else Dim fi As New FileInfo(filePath) Dim list As New List(Of FileInfo) From {fi} _files = list.ToArray End If Catch ex As Exception Throw End Try End Sub Public Sub New(ByVal filePathList As List(Of String)) Try If filePathList Is Nothing Then Throw New _ ArgumentNullException("Collection Of File Paths", _ "Cannot be null." & vbCrLf) ElseIf filePathList.Count = 0 Then Throw New _ ArgumentOutOfRangeException("Collection Of File Paths", _ "Cannot be empty." & vbCrLf) Else Dim list As New List(Of FileInfo) For Each filePath As String In filePathList Dim fi As New FileInfo(filePath) list.Add(fi) Next _files = list.ToArray End If Catch ex As Exception Throw End Try End Sub Public ReadOnly Property Files As System.Collections.Generic.IEnumerable(Of System.IO.FileInfo) _ Implements IFileData.Files Get Return _files End Get End Property End Class


    So you could create your own class and implement IFileData and then pass in an instance of your class to something else that I've created and it would work just exactly the same.

    The class receiving it doesn't have to implement that interface (mine doesn't); it has no idea where the data came from nor does it need to... it needs to know only what IFileData instructs it to have - which in this case is just have a single read-only property.


    If I had eight hours to chop down a tree, I'd spend six sharpening my axe. -- Abraham Lincoln

    Saturday, January 16, 2016 1:40 AM
  • Hi

    What is an interface and what is its need? I have read on it but am not sure on the scope of its need.

    Thanks

    Regards

    I'll post this then I'll shut up and be quiet. ;-)

    *****

    A few years ago, Reed posted the following thread which I thought was a very good "hands on" example of the use:

    https://social.msdn.microsoft.com/Forums/vstudio/en-US/137fdee4-8767-4177-a6fe-c3fc47b3c126/what-are-abstract-classes-for

    It's worth a few minutes to have a look and you'll see a comparison of Interfaces and Inheritance.


    If I had eight hours to chop down a tree, I'd spend six sharpening my axe. -- Abraham Lincoln

    Saturday, January 16, 2016 1:46 AM
  • I like Mr. Smith's analogy of calling an interface a contract.  I guess that's about the only thing I have ever seen an interface be useful at. 

    Back when C++ was first forming, I don't *think* there was any such thing as interfaces as we know it.  I think there was simply inheritance.  You used inheritance to imply "is a" type relationships.  The cool thing about C++ was that it allowed you to have *multiple* base classes per class.  In C++, a horse class could derive both from a vehicle class *and* an animal class.  As you likely already know, this is called multiple inheritance.  Unfortunately, languages that allow multiple inheritance suffer from something called a Diamond Problem:
    https://en.wikipedia.org/wiki/Multiple_inheritance#The_diamond_problem

    I think Java was one of the first well accepted languages to try to avoid Multiple Inheritance.  In Java, I *think* they decided to let each class have only *one* base class.  I think this allowed the author's of Java to avoid the previously mentioned Diamond Problem.  Unfortunately, if each class can only have *one* base class, that severely limits polymorphism and the flexibility of "is a" style relationships.  To fix the polymorphism issue that was created by only allowing one base class per class, I *think* Java came up with the idea of the Interface.

    The Interface in Java *apparently* allowed *multiple* "is a" relationships per class but avoided the Diamond Problem.  I think the Diamond Problem from above only happens when a derived class can inherit multiple *implementations* of a method.  Fortunately, interfaces are *not* implementations but are rather contracts like Mr. Smith said.  Since interfaces provide *no* implementation of code, I think they avoid the Diamond Problem.  The idea of interfaces seem like a compromise to me when language creators don't have time to implement full blown multiple inheritance like what is found in C++.

    I think Java started something.  I think many other languages later decided to avoid multiple inheritance and use "interface" inheritance instead.  I *think* many *.NET languages made this decision also because it would have been overly complicated to implement C++ style inheritance on top of the *.NET CLR.  See Jordão's comment here:
    https://stackoverflow.com/questions/178333/multiple-inheritance-in-c-sharp

    Personally, I would rather we do away with Interfaces and go back to C++ style multiple inheritance.  There were a *few* times in *.NET where I wanted to not only specify multiple "is a" relationships per class but also inherit code implementations from multiple classes.  It has always annoyed me that the current C#/VB.NET design does not seem to allow me to inherit code *implementations* from multiple base classes.

    Even though I no longer work in *.NET and am now a PeopleSoft programmer (hack), I hope for the day when most *.NET languages will support multiple inheritance like C++ does.

    BTW: I happen to consider VB.NET and C# far superior to Java and PeopleCode. I wish Microsoft would come up with an ERP replacement for PeopleSoft Campus Solutions...

    Saturday, January 16, 2016 4:42 AM
  • I like Mr. Smith's analogy of calling an interface a contract.  I guess that's about the only thing I have ever seen an interface be useful at. 

    So you never done unit testing, mocking of objects or used an IoC in Test Driven Design? You have never done Dependency Injection? They all use Interfaces heavily.

    Yes, an Interface is a contract between two objects. A class is just a blueprint for an object that's an instance in memory, which defines the object's behavior. An interface defines the contract that the called object implements that the calling object adheres to.

    Saturday, January 16, 2016 8:56 AM
  • @Shawn

    In C++ does the header .hdr the same. Those who did rely on that a lot, use Interfaces for this in VB.


    Success
    Cor

    Saturday, January 16, 2016 9:53 AM
  • <quote>To Shawn: So you never done unit testing, mocking of objects or used an IoC in Test Driven Design? You have never done Dependency Injection?</quote>

    Sorry if my post was offensive. Thank you for correcting me. I've done Unit Testing (without mocking objects) [1] and have been exposed to factories to some degree. Also, I've probably used sub-frameworks within *.NET that use Dependency Injection under the hood. However, I really don't directly know much (at the time of this post) about Inversion of Control (under the hood). While I may have been required to comply with interfaces to support frameworks that used IoC, I don't think I have ever implemented IoC directly.

    I guess the main *point* of my post was that I thought there was *nothing* an *interface* could do that *multiple inheritance* can't. Isn't it *possible* to do Mocking of Objects, IoC, and Dependency Injection in *Unmanaged* ISO/IEC 14882:1998 C++98?  I don't *think* C++98 has official constructs for interfaces. 

    I apologize if my post may not have been totally accurate, but I believe *part* of it is still correct so I am leaving it there. I *suppose* it's good for me that we aren't on StackOverflow...

    [1] - Yes, it is possible to unit test without Mocking Objects; however, I suppose there may be things that are difficult to test without doing such mocking.

    Sunday, January 17, 2016 9:29 PM
  • @Shawn

    In C++ does the header .hdr the same. Those who did rely on that a lot, use Interfaces for this in VB.

    I think I follow what you are saying.  I hadn't thought about that before. 

    Prior to VB.NET, I generally separated the specification and implementation.  Unfortunately, with VB.NET and C# both specification and implementation have to be in the same file unless you do *trickery* with interfaces or partial classes.

    I suppose an Interface in a C# file could function similar to a header like you said.  I guess since no implementation is provided in interfaces, a file for a C# interface kind of looks like a C/C++ header.  Eventually, however, something would inherit the interface.  Once the interface is inherited, the implementation would then have to be provided.  Once an interface is inherited, the inheriting C# file might not have a direct way to further separate the specification and implementation into separate files.

    I think F# solves this another way.  I *think* F# allows you to have signature files (*.fsi) which seem to behave much like C/C++ header files:
    https://msdn.microsoft.com/en-us/library/dd233196.aspx

    Sunday, January 17, 2016 9:56 PM
  • I guess the main *point* of my post was that I thought there was *nothing* an *interface* could do that *multiple inheritance* can't. Isn't it *possible* to do Mocking of Objects, IoC, and Dependency Injection in *Unmanaged* ISO/IEC 14882:1998 C++98?  I don't *think* C++98 has official constructs for interfaces. 

    Let's remember the forum you are posting to, which is  a .NET  forum that uses managed code. Anything else you are trying to convey here is kind of moot point and doesn't apply.

    http://www.codeproject.com/Articles/465173/Dependency-Inversion-Principle-IoC-Container-Depen

    https://en.wikipedia.org/wiki/Test-driven_development

    https://en.wikipedia.org/wiki/Domain-driven_design

    All of the above is marching through as a must particularly so on the C# side with Web development, SOA, any solution dealing with N-tier and Separation of Concerns.

    https://www.google.com/?gws_rd=ssl#q=separation+of+concerns

    I can't say so much on the VB.NET side if hardly at all is it happening like it is in C# development.

    Interfaces are being used heavily on the C# side, but I can't say the same about VB.NET.

    Sunday, January 17, 2016 10:30 PM
  • DA924:

    I apologize if I have offended you or anyone at Microsoft and I appreciate you trying to enlighten me, but I have *always* seen Interfaces as a *limited* version of the more superior technique called "Multiple Inheritance".

    At the time of this post, I believe Tomasz Nurkiewicz said the following over in StackOverflow:
    "Interfaces aren't used to achieve multiple inheritance. They replace it with safer, although slightly less powerful construct." - https://stackoverflow.com/questions/8531292/why-to-use-interfaces-multiple-inheritance-vs-interfaces-benefits-of-interface

    This statement by Mr. Nurkiewicz *seems* to imply that Interfaces are inferior way to do something that can also be done by the more powerful Multiple Inheritance mechanism.  So I continue to wonder if VB.NET and C# will ever support Multiple Inheritance and do away with the Interface technique that seems to have been made popular by Java.  It *seems* to me that if C# and VB.NET supported Multiple Inheritance, we wouldn't need Interfaces anymore.

    As far as the techniques you mentioned, I have had *some* level of exposure to many of them, but I obviously don't know as much as you do.  In regards to VB.NET and C#, I have worked with both and consider them nearly identical.  F#, on the other hand, seems quite different from both VB.NET and C#.

    However, I would like to thank you, Mr. Ligthert and every one else for helping me to learn from this discussion.

    Thanks,

    Shawn


    • Edited by Shawn Eary Monday, January 18, 2016 5:09 PM rewording of statement regarding multiple inheritance
    Monday, January 18, 2016 5:02 PM
  • Shawn,

    I can only speak for myself, but I appreciate you bringing these things into discussion.

    Everyone doesn't have to agree with everyone else's point of view, but sharing the information is always a good thing. :)

    *****

    Multiple inheritance - hmm. It seems to me that it would be more confusing than helpful, but obviously my perspective is tainted.

    At any rate though, it's food for thought. :)


    If I had eight hours to chop down a tree, I'd spend six sharpening my axe. -- Abraham Lincoln

    Monday, January 18, 2016 5:34 PM
  • Yea but this is the VB forum. For C# questions and answers try this forum.

    https://social.msdn.microsoft.com/Forums/vstudio/en-US/home?forum=csharpgeneral

    By the way there is not any difference between a C# interface and a VB interface.

    As well, multiple inheritance is expressly not included in VB and C# because it causes to much problems when used, not because it was to much trouble to include. The same why for instance designer forms arrays are not included (that gave bad non OOP code by thousand of Select Case statements).

    Be aware that the interface solves more problems. For instance when polyphormism is used. 


    Success
    Cor



    Monday, January 18, 2016 5:54 PM
  • Shawn

    First off, you have not offended anyone. I am just bringing the facts. 

    This statement by Mr. Nurkiewicz *seems* to imply that Interfaces are inferior way to do something that can also be done by the more powerful Multiple Inheritance mechanism.  So I continue to wonder if VB.NET and C# will ever support Multiple Inheritance and do away with the Interface technique that seems to have been made popular by Java.  It *seems* to me that if C# and VB.NET supported Multiple Inheritance, we wouldn't need Interfaces anymore.

    I don't know about multiple inheritance, but I suspect that usage of Interfaces will remain as is in .NET with C# and VB for some time to come, particularly so with MS's Service Oriented Architecture -- WCF. A WCF service uses an Interface to define its public Operational Contracts (behavior) it exposes to the WCF client. And WCF is a core development solution with .NET technology centered around WCF. 

    Note: MS and Sun Micro Systems with SMS owning Java at the time went to war over Java usage on the MS platform, and therefore you have .NET.  Also, MS doesn't own .NET or C# for sure, which is controlled by the ISO and ECMA Standards Committee, which MS is just one member of the committee with 1 vote out of multiple committee members. 

    Monday, January 18, 2016 6:11 PM