Prev | Current Page 191 | Next

Guy Fouch?©, Trey Nash

"Accelerated VB 2008"


nCaution We strongly recommend that you do not modify a publicly published interface.
CHAPTER 6 n INTERFACES 110
You could also address this problem by defining a completely new interface, say
IMyOperations2. However, ClientClass would need to implement both interfaces in order
to get the new behavior, as shown here:
Public Interface IMyOperations
Sub Operation1()
Sub Operation2()
End Interface
Public Interface IMyOperations2
Sub Operation1()
Sub Operation2()
Sub Operation3()
End Interface
Public Class ClientClass
Implements IMyOperations, IMyOperations2
Public Sub Operation1() Implements IMyOperations.Operation1
' Do op 1
End Sub
Public Sub Operation2() Implements IMyOperations.Operation2
' Do op 2
End Sub
Public Sub Operation21() Implements IMyOperations2.Operation1
' Do op 2.1
End Sub
Public Sub Operation22() Implements IMyOperations2.Operation2
' Do op 2.2
End Sub
Public Sub Operation3() Implements IMyOperations2.Operation3
' Do op 2.3
End Sub
End Class
Public Class AnotherClass
Public Sub DoWork(ByVal ops As IMyOperations)
' Do ops
End Sub
End Class
Modifying ClientClass to support the new operation from IMyOperations2 isn??™t terribly
hard, but what about the code that already exists, such as the DoWork method in AnotherClass?
The problem is that DoWork() accepts an argument of type IMyOperations.


Pages:
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203
zakłady bukmacherskie Wczasy nad morzem oferty spa Spa Ciechocinek kolokacja rack