cjard
Well-known member
- Joined
- Apr 25, 2006
- Messages
- 7,081
- Programming Experience
- 10+
Suppose I have two interfaces and I make a method that is overloaded:
Method(IOne)
Method(ITwo)
If I have 3 classes that inherit from a base class:
Dim b as Base = New OneImpl
Dim c as Base = New TwoImpl
Dim d as Base = New OneTwoImpl
What happens in each of these case:
Method(b)
Method(c)
Method(d)
Presumably I cant just use this, and I will have to interrogate the type myself and call the relevant overload with a cast?
I ask because I actually have 4 classes, 3 interfaces and they overlap somewhat:
ISignable - the request obeys a security procedure
IChargeable - the request holds credit card info
IReconcilable - the request holds daily transaction totals
(I'm also struggling as to whether to name these adjectives or nouns: ISignature, ICreditCardInfo, IReconciliationInfo)
Abstract BaseRequest that all below inherit from:
AuthRequest Implements IChargeable
ChargeRequest Implements ISignable, IChargeable
ReconRequest Implements ISignable, IReconcilable
ChargeRequest could inherit from BasicRequest and just implement ISignable. Dont know if this would help
So my question here is, is this the best way to arrange this and can I get away with making an overloaded ProcessRequest and calling:
ProcessRequest(myRequest)
Is there a way of arranging the overloads so that the reconcile is done if the myRequest is IReconcilable, the charge is done if (blah blah) and the auth is done if.. (balh blah)
Or will it have to be:
if(myREquest Is IReconcilable AndAlso myrequest Is ISignable) Then ProcessSignableCharge(myRequest)
...
Method(IOne)
Method(ITwo)
If I have 3 classes that inherit from a base class:
Dim b as Base = New OneImpl
Dim c as Base = New TwoImpl
Dim d as Base = New OneTwoImpl
What happens in each of these case:
Method(b)
Method(c)
Method(d)
Presumably I cant just use this, and I will have to interrogate the type myself and call the relevant overload with a cast?
I ask because I actually have 4 classes, 3 interfaces and they overlap somewhat:
ISignable - the request obeys a security procedure
IChargeable - the request holds credit card info
IReconcilable - the request holds daily transaction totals
(I'm also struggling as to whether to name these adjectives or nouns: ISignature, ICreditCardInfo, IReconciliationInfo)
Abstract BaseRequest that all below inherit from:
AuthRequest Implements IChargeable
ChargeRequest Implements ISignable, IChargeable
ReconRequest Implements ISignable, IReconcilable
ChargeRequest could inherit from BasicRequest and just implement ISignable. Dont know if this would help
So my question here is, is this the best way to arrange this and can I get away with making an overloaded ProcessRequest and calling:
ProcessRequest(myRequest)
Is there a way of arranging the overloads so that the reconcile is done if the myRequest is IReconcilable, the charge is done if (blah blah) and the auth is done if.. (balh blah)
Or will it have to be:
if(myREquest Is IReconcilable AndAlso myrequest Is ISignable) Then ProcessSignableCharge(myRequest)
...