Re: Forms inheritance best practice
From: Jonathan Allen (x_at_x.x)
Date: 09/27/04
- Next message: Jonathan Allen: "Re: Negative Numbers?"
- Previous message: Bernie Yaeger: "Re: Negative Numbers?"
- In reply to: Daniel Billingsley: "Forms inheritance best practice"
- Next in thread: Daniel Billingsley: "Re: Forms inheritance best practice"
- Reply: Daniel Billingsley: "Re: Forms inheritance best practice"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 27 Sep 2004 16:45:13 -0700
That really depends on the nature of your base class. I only use form
inheritance for visual features like a toolbar or menu that has to be on
every form.
-- Jonathan Allen "Daniel Billingsley" <dbillingsley@NO_durcon_SPAAMM.com> wrote in message news:%23doLnjMpEHA.3712@TK2MSFTNGP15.phx.gbl... > My application will have various forms for editing my business objects. All > the objects to be edited on the various forms will either derive from a > common class or implement a common interface. Let's just say it's an > interface for sake of this discussion. > > There is a lot of common functionality between the forms, of course. Using > forms inheritance seemed like a great way to reuse that common code. > > Of course there are some parts of the common code that need to interact with > the interface, but the actual business object appropriate for the particular > derived form will of course be instantiated by the derived form. The > controls specific to editing that type of business object will of course be > on the derived form. > > So, it seemed logical to create some abstract methods and properties in the > base form. That means the class itself must be abstract. Not so fast - the > designer complains it needs to instantiate the base class and can't because > it's abstract. > > Hmmm.. > > That leaves me with two options that I can see. I'm just wondering which is > considered a better practice, or if there's a third I haven't thought of. > > 1) Declare protected fields (of the interface Type) in the base form which > could be set directly in the derived form in all the appropriate places. > > 2) Declare the needed methods and properties as virtual in the base class. > In the base class each simply throws a NotSupportedException since only the > override in the derived form should actually be used. > >
- Next message: Jonathan Allen: "Re: Negative Numbers?"
- Previous message: Bernie Yaeger: "Re: Negative Numbers?"
- In reply to: Daniel Billingsley: "Forms inheritance best practice"
- Next in thread: Daniel Billingsley: "Re: Forms inheritance best practice"
- Reply: Daniel Billingsley: "Re: Forms inheritance best practice"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|
Loading