Code Resuse?
Here is an interesting question, I've a couple of UI Controls, which are remarkably similiar, and share the same base class. The only differences are some strings that are displayed to the user, and the result of some action. I'm using the controls as a way to create instances of a base class, so you may think of them as a UI Factory. The issue is generating the following UI:
Owner: ....
-- this is a per control area
Color: ...
Sterile: ...
--- end of per control area
Save / Delete
Right now the form is responsible for loading the data, and the control is reponsible for creating/saving & displaying it. In many cases, all I need to do is to change the names of the fields and the type that is created. I can create some sort of a base class to do it, and I can probably do it cleanly, but is it worth it?
Right now I simply copy & pasted the code and made the neccecary changes. The changes I needed to do are minor, but they represent different objects entirely (a German Shepherd vs. Poodle, for instnace). The form sees all of those controls as a single base class, and doesn't care which object it creates or display.
What do you think?
Comments
Comment preview