I have read several questions on here and it appears that the general consensus is that an interface is not required for every class in a project. I have read posts like this: Is it the best practice to extract an interface for every class?.
I want to know how this applies to the .NET framework classes. I believe that all of the classes I have looked at either inherit from an abstract class e.g. SQLConnection inherits from dbConnection or implement and interface e.g. the Component class implements the IComponent interface.
I have a copy of Reflector, which I downloaded two months ago and I am awaiting the license (paid the fee recently). When I start to step through the code (using Reflector); am I going to see code like this:
Public Class Foo
Public Name As String
Public Property NameProperty()
Get
Return Name
End Get
Set(value)
Name = value
End Set
End Property
Public Shared Sub Main()
Dim f As Foo = New Foo
f.NameProperty = "Ian"
End Sub
End Class
rather than code like this:
Public Class Foo
Implements IFoo
Public Name As String
Public Property NameProperty() Implements IFoo.NameProperty
Get
Return Name
End Get
Set(value)
Name = value
End Set
End Property
Public Shared Sub Main()
Dim f As IFoo = New Foo
f.NameProperty = "Ian"
End Sub
End Class
Public Interface IFoo
Property NameProperty()
End Interface
Notice that there is an Interface used in the second code fragment. I am still struggling to understand when it is suitable not to use interfaces. Some developers say never. I suppose some of it is subjective.