Re: Forms inheritance best practice

From: Jonathan Allen (x_at_x.x)
Date: 09/27/04


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.
>
>


Relevant Pages

  • Re: Unification of Methods and Functions
    ... I am suggesting that we write factory methods using classmethod to give ... my classes all implement an interface which I'll call 'shape ... Rectangle and Ellipse have a common base class, ...
    (comp.lang.python)
  • Re: Do all OOM objects support the IMessage interface?
    ... OutlookSpy - Outlook, CDO ... > works of a generic interface to Outlook items. ... > specializations of some base functionality, I look for a base class ... the closest I have come to this with the OOM objects is the common ...
    (microsoft.public.win32.programmer.messaging)
  • Re: Accessing inherited variables
    ... derived form so they can be accessed? ... If the variable needs to be access outside the class and its ... variable through the property even in the base class. ... Protected Sub AddItem ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Forms inheritance best practice
    ... If your objective is to provide an interface for your users to edit ... > My application will have various forms for editing my business objects. ... > derived form will of course be instantiated by the derived form. ... > 2) Declare the needed methods and properties as virtual in the base class. ...
    (microsoft.public.dotnet.framework)
  • Re: Interfaces Question - I am missing something
    ... With an interface, _any_ class can implement the interface, and code that relies on the interface will "just work". ... Again, the actual implementation can be done long after the code that uses the implementation was written, because it complies with the contract defined in the base class that the using code _does_ know about. ... In Java, all methods are virtual by default, making this sort of thing that much more common and important ). ... since you're asking the question I assume that you're relatively new to OOP. ...
    (comp.lang.java.programmer)

Loading