C
Chad
I get the jist of this Inheritance stuff, I think, I'm just looking to
understand better...
I created a MustInherit base class with a constructor that had arguments.
Within the constructor method, the param values were mapped (or saved to)
module level PRIVATE variables. I decided on PRIVATE module variables over
PROTECTED because I reasoned that if I NEEDED to expose the module level
variables to the classes that inherited from my base class, I could do so
later. Until then, they were private.
I then created a subclass that had a constructor of its own. On this
constructor, I called, MyBase.New, which passed the param of the subclass's
constructor to the base class, so the base class could initialize itself.
One drawback of passing the sub class's constructor params to the base
class, I found, is this: The first line of the sub class had to be
MyBase.New, which meant, I could not add logic prior to this call to alter
or derive the parameter values before I pass them to the base class
constructor. This is probably atypical, although I got around the issue by
using a complex IIF statment within the My.New all.
My question is this: Someone suggested to me that I should have classed the
module level variables of my base class as protected and directly
initiatlized them from the sub class.
Is there a reason why one approach would be distinctively bette rthan the
other?
understand better...
I created a MustInherit base class with a constructor that had arguments.
Within the constructor method, the param values were mapped (or saved to)
module level PRIVATE variables. I decided on PRIVATE module variables over
PROTECTED because I reasoned that if I NEEDED to expose the module level
variables to the classes that inherited from my base class, I could do so
later. Until then, they were private.
I then created a subclass that had a constructor of its own. On this
constructor, I called, MyBase.New, which passed the param of the subclass's
constructor to the base class, so the base class could initialize itself.
One drawback of passing the sub class's constructor params to the base
class, I found, is this: The first line of the sub class had to be
MyBase.New, which meant, I could not add logic prior to this call to alter
or derive the parameter values before I pass them to the base class
constructor. This is probably atypical, although I got around the issue by
using a complex IIF statment within the My.New all.
My question is this: Someone suggested to me that I should have classed the
module level variables of my base class as protected and directly
initiatlized them from the sub class.
Is there a reason why one approach would be distinctively bette rthan the
other?