T
tshad
I am playing with Inheritance and want to make sure I understand it.
I have the following Classes:
*******************************************
Public Class AuthHeader:Inherits SoapHeader
Public AuthHeaderName As String
Public SessionKey As String = "Default"
End Class
Public Class ServiceTicket:Inherits AuthHeader
Public IsAuthenticated As Boolean
Public SessionKey As String = "Default from ServiceTicket"
Public Expiration As DateTime
End Class
Public Class TempClass1:Inherits ServiceTicket
Public TomsClass1Name As String
End Class
*****************************************
I assume that inheritance depends on the order of definition.
Here SessionKey is being defined in 2 classes. For TempClass1 and
ServiceTicket, Session would be "Default from ServiceTicket" since it would
have been defined second. So if I create TempClass1, it would work
something like, SessionKey would first be "Default" but then ServiceTicket
would re-define it, since it inherited it (and is higher up the chain) and
change it to "Default from ServiceTicket".
In this case, if I had:
Dim objTempClass1 As new TempClass1
Dim objServiceTicket As new ServiceTicket
Dim objAuthHeader As new AuthHeader
objTempClass1.SessionKey = "Default from ServiceTicket" '
Inherited from ServiceKey
objServiceKey.SessionKey = "Default from ServiceTicket"
objAuthHeader.SessionKey = "Default"
But if I took out the Sessionkey from the ServiceKey class that it would be:
objTempClass1.SessionKey = "Default" ' Inherited from
AuthHeader
objServiceKey.SessionKey = "Default" ' Inherited
from AuthHeader
objAuthHeader.SessionKey = "Default"
Also, I originally got this from a sample program that didn't set the
defaults, but had it defined as:
*******************************************
Public Class AuthHeader:Inherits SoapHeader
Public AuthHeaderName As String
Public SessionKey As String
End Class
Public Class ServiceTicket:Inherits AuthHeader
Public IsAuthenticated As Boolean
Public SessionKey As String
Public Expiration As DateTime
End Class
Public Class TempClass1:Inherits ServiceTicket
Public TomsClass1Name As String
End Class
*****************************************
Is there any good reason to defining SessionKey again ServiceTicket?
I assume since it always would inherit from AuthHeader, it would always get
SessionKey from the inheritance. If it wanted to set SessionKey in
ServiceTicket, it could just set it by:
SessionKey = "Default"
without needing to redefine it.
Is this correct?
Thanks,
Tom
I have the following Classes:
*******************************************
Public Class AuthHeader:Inherits SoapHeader
Public AuthHeaderName As String
Public SessionKey As String = "Default"
End Class
Public Class ServiceTicket:Inherits AuthHeader
Public IsAuthenticated As Boolean
Public SessionKey As String = "Default from ServiceTicket"
Public Expiration As DateTime
End Class
Public Class TempClass1:Inherits ServiceTicket
Public TomsClass1Name As String
End Class
*****************************************
I assume that inheritance depends on the order of definition.
Here SessionKey is being defined in 2 classes. For TempClass1 and
ServiceTicket, Session would be "Default from ServiceTicket" since it would
have been defined second. So if I create TempClass1, it would work
something like, SessionKey would first be "Default" but then ServiceTicket
would re-define it, since it inherited it (and is higher up the chain) and
change it to "Default from ServiceTicket".
In this case, if I had:
Dim objTempClass1 As new TempClass1
Dim objServiceTicket As new ServiceTicket
Dim objAuthHeader As new AuthHeader
objTempClass1.SessionKey = "Default from ServiceTicket" '
Inherited from ServiceKey
objServiceKey.SessionKey = "Default from ServiceTicket"
objAuthHeader.SessionKey = "Default"
But if I took out the Sessionkey from the ServiceKey class that it would be:
objTempClass1.SessionKey = "Default" ' Inherited from
AuthHeader
objServiceKey.SessionKey = "Default" ' Inherited
from AuthHeader
objAuthHeader.SessionKey = "Default"
Also, I originally got this from a sample program that didn't set the
defaults, but had it defined as:
*******************************************
Public Class AuthHeader:Inherits SoapHeader
Public AuthHeaderName As String
Public SessionKey As String
End Class
Public Class ServiceTicket:Inherits AuthHeader
Public IsAuthenticated As Boolean
Public SessionKey As String
Public Expiration As DateTime
End Class
Public Class TempClass1:Inherits ServiceTicket
Public TomsClass1Name As String
End Class
*****************************************
Is there any good reason to defining SessionKey again ServiceTicket?
I assume since it always would inherit from AuthHeader, it would always get
SessionKey from the inheritance. If it wanted to set SessionKey in
ServiceTicket, it could just set it by:
SessionKey = "Default"
without needing to redefine it.
Is this correct?
Thanks,
Tom