Design / Good practices question

J

Jorge

Hello,

I've got a question. I'm developing an application in C#, in three
layers.

Well... i've got several entities, all of them, of course, can be
created / modified / deleted.

I've written, in the UI layer, a superclass, which is inherited by
every "entity form", with methods, for instance, for the Add /
Update / Delete buttons.

All i need to do in every form, is just add the event handler of every
button, linking to the method of the superclass, and pass some
references of UI components, which are shown / hidden as needed (Load
or Update panels, showing the buttons).


Is this the best way to do this ??? is there any design pattern
appliable to this situation ?. This works fine... but i kinda feel
unconfortable with the code.

Thank you very much, in advance.!
 
S

Steve Gerrard

Jorge said:
Hello,


I've written, in the UI layer, a superclass, which is inherited by
every "entity form", with methods, for instance, for the Add /
Update / Delete buttons.

Is this the best way to do this ??? is there any design pattern
appliable to this situation ?. This works fine... but i kinda feel
unconfortable with the code.

Don't know if it is what you are after or not, but it sounds to me like you
could make a base form, then derive your various entity forms from that. The
base form could already have the Add/Update/Delete buttons, and related wiring.
The derived forms could override methods or change settings as needed.
 
J

Jorge

That's right Jerry, that's what i'm after for. I'll just put the add /
update / delete buttons in the superclass... and if the subclass don't
allow update / delete, i'll just pass that information in the
constructor, and avoid the creation of those objects.

Thanks for your help :D
 
S

Steve Gerrard

Jorge said:
That's right Jerry, that's what i'm after for. I'll just put the add /
update / delete buttons in the superclass... and if the subclass don't
allow update / delete, i'll just pass that information in the
constructor, and avoid the creation of those objects.

Thanks for your help :D

If it were me, I would just hide them. :) Or rather, have them start hidden, and
show the ones desired. Put ShowButtons() and EnableButtons() methods in the base
class (if its just three buttons, passing 3 flags would work), then call those
in the instance classes whenever needed.
 

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