Inheriting from Base Classes (Public Interfaces)

  • Thread starter Thread starter Charles Law
  • Start date Start date
C

Charles Law

I have a base class - ComponentBase - that inherits from UserControl. My
class implements IComponentBase, which defines a minimal set of core
properties and methods. All my other components inherit from ComponentBase.

I have defined IComponentBase in a common assembly so that my other projects
reference this rather than the (large) library that contains the component
implementation.

[Stop me when I start to go off the rails]

Now, because UserControl is actually at the heart (base) of all my
components, I automatically get properties like Width, Height, Left, Top,
etc. I also get events like LocationChanged, MouseEnter, and so on.

So that I can attach to the MouseEnter event, and others, I find that I have
to define a MouseEnter event in my interface, implement it in my base class,
and override OnMouseEnter in by base class to call MyBase.OnMouseEnter and
raise my event, which shadows the one in UserControl. It seems that I have
to do this for every event I want to attach to.

I also find that if I want to refer to the Width property of UserControl, I
have to define it in my interface and override it in my base class.

This seems like a lot of code that, basically, just passes things on to the
UserControl base class, and it is very tedious and, of course, error prone.

Am I going about this the right way, or is there an easier solution?

TIA

Charles
 
Doesent sound too maintainable to me. It also sounds like hard work, Im
simply too lazy, if it was giving me performance problems, I would probably
specify faster computers.

I know thats not the answer you were expecting. Good Luck !

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .

Time flies when you don't know what you're doing
 
Aaarrgh! }-:-|-[

---
I used a spell checker, and apparently 'Earth' comes a close second.


One Handed Man ( OHM - Terry Burns ) said:
Doesent sound too maintainable to me. It also sounds like hard work, Im
simply too lazy, if it was giving me performance problems, I would probably
specify faster computers.

I know thats not the answer you were expecting. Good Luck !

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .

Time flies when you don't know what you're doing

Charles Law said:
I have a base class - ComponentBase - that inherits from UserControl. My
class implements IComponentBase, which defines a minimal set of core
properties and methods. All my other components inherit from ComponentBase.

I have defined IComponentBase in a common assembly so that my other projects
reference this rather than the (large) library that contains the component
implementation.

[Stop me when I start to go off the rails]

Now, because UserControl is actually at the heart (base) of all my
components, I automatically get properties like Width, Height, Left, Top,
etc. I also get events like LocationChanged, MouseEnter, and so on.

So that I can attach to the MouseEnter event, and others, I find that I have
to define a MouseEnter event in my interface, implement it in my base class,
and override OnMouseEnter in by base class to call MyBase.OnMouseEnter and
raise my event, which shadows the one in UserControl. It seems that I have
to do this for every event I want to attach to.

I also find that if I want to refer to the Width property of
UserControl,
I
have to define it in my interface and override it in my base class.

This seems like a lot of code that, basically, just passes things on to the
UserControl base class, and it is very tedious and, of course, error prone.

Am I going about this the right way, or is there an easier solution?

TIA

Charles
 
Back
Top