Forced Override question?

M

Mark Essex

I am trying to build an interface that requires the developer to use the
OVERRIDE option. I looked at abstract classes, but seemed to have a couple
of problems:

1. If you do this in a form, it appears that I can't get the designer to
display the derived forms
2. It forces the override in the derived form (form A), but if another form
(form B) derives from this derived form (form A), it isn't forced to
override the method.

Basically, I have the following:

Form A -> Form B -> Form C -> Form D


I want Form D to HAVE to implement a method called RefreshScreen() with the
override option.

Any thoughts on how I can do this? Form A is the base form that has a
RefreshScreen() method in it.

I have also tried to build an interface, and it requires the developer to
implement the RefreshScreen() method, but they don't have to OVERRIDE it,
and if they don't, then one of the base forms RefreshScreen() method gets
called.

Mark
 
N

Nick Malik

I'm trying to understand just which design pattern would recommend that you
create an inheritance tree that is four concrete classes deep!

Instead of having D inherits C inherits B inherits A, why not have:
A, B, C, and D inherits Form and interface XX

The use one of the Gang-of-four patterns to derive the functionality you
want.
See http://home.earthlink.net/~huston2/dp/patterns.html (Probably my
favorite intro link for design patterns, but there are thousands... Google
"Design Patterns" )

Good luck,

--- Nick
 
M

Mark Essex

Thanks, I will check out the link. To explain a little more of WHY I am
doing it this way:

I have a Framework I built which is pretty generic. It provides an SDI
style interface, which includes handling of all forms in the SDI interface.
This is Level 1 (SDIChildForm). I then have an Application built on top of
that. There are application-specific things that have nothing to do with
the more generic framework (ex. Patient handling), so I have a base form
(AppSDIChildForm) that inherits from the SDIChildForm, and adds additional
methods, properties, etc. that are app-specific. Now, both of these forms
are just blank forms with some common methods and properties that interact
with the SDI framework. That's it. Next I have, for example, a Base 'Edit'
form (BaseEditForm), which is a specific 'form style' that I am using for
several of my forms in the application. It contains as much implementation
detail as possible about a specific form style (This is Level 3). I then
have specific forms that inherit from this Level 3 form to provide
application specific information.

Basically, the framework will call, for example, a RefreshScreen() method
whenever a specific form becomes the active form. Depending on the form,
the implementation of the RefreshScreen() is specific to that form. I need
to handle the refresh for each form differently. However, I want the main
framework to handle the RefreshScreen() call whenever appropriate. If the
RefreshScreen() method is overriden, then it will call the app-specific form
refresh at the appropriate time. This works well...I am just trying to
enforce that the Developer building the forms HAS to override to ensure
proper refresh on each form.

Make sense or am I off the wall here?

Thanks again,

Mark
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top