Hi gang,
I have a silly question... silly in that I have been an OO developer for almost 19 years now, and this issue just hit me in
VB.NET, and I am not sure if my thinking is correct for the language.
I have an abstract class DataBroker, and I want to force all derived classes to implement some specific functionality. One of those methods is Delete.
Now in the DataBroker abstract class, I write the method template:
Code:
Public MustOverride Function Delete(ByVal aBO as BO) As Boolean
BO is an object that will be passed as an example of what to delete.
In my subclass, PersonDataBroker, I override the function:
Code:
Public Overrides Function Delete(ByVal aPerson as Person) As Boolean
Note that Person IS a subclass of BO.
This causes an error saying that I have not overridden the method, assumedly because the passed types differ.
So, here is the deal... I want to force subclasses to implement this method, but the subs will know what specific BO type they are getting. I need to be able to call functionality on the specific BO type (i.e. Person) in the specialized data broker (i.e. PersonDataBroker).
With me so far?
So, it seems to be that I need to OverLOAD the abstract function... but for some reason that just feels wrong.
Am I missing something here or is this the way to do it?
I was going to use Generics, but that does not seem to fit the bill properly either.
Any help greatly appreciated!
Chris