multiple inheritance alternative please.

  • Thread starter Thread starter vidalsasoon
  • Start date Start date
V

vidalsasoon

I have a class "SomeForm" that inherits a "Global" class which in turn
inherits "System.Windows.Forms.Form". As you may have guessed all my
other classes that are inheriting from "Global" are also picking up on
the "Form" fudge. Since I only have one form in my app, it bothers me
that "Global" is so obese.

I would like to clean this up a little.


I was thinking of setting "Global" as an interface but i'm not sure how
I could maintain the staticness of my class.

I know global variables are frowned on but if I had to pass my global
object along everywhere... it would suck.

I also thought of singleton for my global class but felt it would be
awkward to set variables with.


I'm still not all that comfortable with OO and could use some input.
any objections to my approach appreciated.

V.
 
vidalsasoon said:
I have a class "SomeForm" that inherits a "Global" class which in turn
inherits "System.Windows.Forms.Form". As you may have guessed all my
other classes that are inheriting from "Global" are also picking up on
the "Form" fudge. Since I only have one form in my app, it bothers me
that "Global" is so obese.

Can you explain what you are trying to do.
I know global variables are frowned on but if I had to pass my global
object along everywhere... it would suck.

There's nothing wrong with using a global variable when appropriate.

Michael
 
vidalsasoon said:
I have a class "SomeForm" that inherits a "Global" class which in turn
inherits "System.Windows.Forms.Form". As you may have guessed all my
other classes that are inheriting from "Global" are also picking up on
the "Form" fudge. Since I only have one form in my app, it bothers me
that "Global" is so obese.

I would like to clean this up a little.


I was thinking of setting "Global" as an interface but i'm not sure how
I could maintain the staticness of my class.

I know global variables are frowned on but if I had to pass my global
object along everywhere... it would suck.

I also thought of singleton for my global class but felt it would be
awkward to set variables with.

You could easily create a static class to hold your globals which would
then function very similarly to a global in a bas module in vb6.

It does not sound like the global class inheriting from form is the
right way to go.

What "globals" do you need?

JB
 
well i'll be damned.

All this time I thought we had to inherit from a base class to maintain
"persistence". This is gonna make things a lot easier.

xox.
 
Back
Top