Why the interface / implements ?? OOP clarrification

  • Thread starter Thread starter wildman
  • Start date Start date
W

wildman

Looking at an asp.net website with a lot of OOP and I am trying to
understand where the benefit of all this might be.


There is a user control with codebehind properties that looks like
this:


Partial Class uc
Inherits System.Web.UI.UserControl
Implements UM.IUIBuildingBlock

Public Property Checked() As Boolean Implements
XX.IUIBuildingBlock.Checked
Get
Return Nothing
End Get
Set(ByVal Value As Boolean)
End Set
End Property
 
Well, it would be very hard to guess what the developer was doing based on
the little code you are showing. Obvoiously the the Checked property is
meant to be shadowed somewhere else since it does not do anything. Also the
class (as you have shown it) does not implement UM.IUIBuildingBlock, since it
does not implement the DataType property.
In general, interfaces are an important concept. In one of my projects, I
have an entire dll that is nothing but interfaces. They are meant to be used
by the 'clients' of the application. In particular, since some of those
clients may be 'COM' types like VBA and VB6 it is strongly recomended that
you explicitly define the interface(s), else you may be 'breaking' COM
clients by doing simple changes in your project. Seems to me I read that
even chaning the order of routines in the class could cause a COM client to
break, unless you have explcitly defined the interface.
Also, interfaces alow a class to 'behave' like many different things.
 
Back
Top