473,382 Members | 1,526 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Inheriting from Base Classes (Public Interfaces)

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
Nov 20 '05 #1
2 1467
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" <bl***@nowhere.com> wrote in message
news:uN**************@TK2MSFTNGP09.phx.gbl...
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

Nov 20 '05 #2
Aaarrgh! }-:-|-[

---
I used a spell checker, and apparently 'Earth' comes a close second.
"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
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" <bl***@nowhere.com> wrote in message
news:uN**************@TK2MSFTNGP09.phx.gbl...
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


Nov 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: C.E.O. Gargantua | last post by:
Is it possible for a class to inherit from two interfaces? When I try to add a second interface, and compile, the error is: type in interface list is not an interface related to the...
3
by: thechaosengine | last post by:
Hi all, I wanted to put some common security functions into a class that inherits from the Page class and then use the new class as the basis for all my pages. Unfortunately, if I try and...
2
by: Peter Bates | last post by:
Hi, I'm just getting used to XSDObjectGen and i have the following question. Can i use a class inherited from a class generated by XSDObjectGen with XmlSerialize? Specifically, I have many...
11
by: Noah Coad [MVP .NET/C#] | last post by:
How do you make a member of a class mandatory to override with a _new_ definition? For example, when inheriting from System.Collections.CollectionBase, you are required to implement certain...
9
by: Sean Kirkpatrick | last post by:
To my eye, there doesn't seem to be a whole lot of difference between the two of them from a functional point of view. Can someone give me a good explanation of why one vs the other? Sean
1
by: jbzdak | last post by:
Recently, I have been learning Java (it is one of laboratories on my department), well I know Java is awfully slow, but it is not the point that I'm interested. Java has a keyword "interface. (and...
24
by: toton | last post by:
Hi, I want to have a vector like class with some additional functionality (cosmetic one). So can I inherit a vector class to add the addition function like, CorresVector : public...
2
by: cmonthenet | last post by:
Hello, I searched for an answer to my question and found similar posts, but none that quite addressed the issue I am trying to resolve. Essentially, it seems like I need something like a virtual...
4
by: AalaarDB | last post by:
struct base { int x, y, z; base() {x = 0; y = 0; z = 0;}; base(int x1, int y1, int z1) {x = x1; y = y1; z = z1;}; }; struct intermediate1 : public virtual base {}; struct intermediate2 :...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.