views:

48

answers:

2

I made a .NET Windows form that allows users to view a particular document and sign it.

I want to make it re-usable for future applications.

The challenges are:

  1. The text to be signed requires parameters.
  2. Before the user signs it, the text is just a query - not saved anywhere
  3. When the user signs it, the text he/she signed must be stored and "frozen". In future executions of the query, the data may change
  4. Different documents could have different data sources and different parameters. But they all should be saved in the same table when signed

I can only think of making a new class for every document and inheriting from the same class with the same base functionality. Is there a better way to do this? Based on a parameter, can I load a different data source and template?

+1  A: 

I think you may choose MVC model-view -controller or MVP pattern. So you can keep your rules (challenges) in Controler layer. This helps you to add other views(windows) to existed controller or switch data model.

http://en.wikipedia.org/wiki/Model–view–controller

Arseny
+1 Thanks for replying. I will wait in case there are other suggestions.
HappyCoder4U
+1  A: 

Convert the form into a control, packaged into it's own assembly (probably a Windows Forms Control Library) - that way it will be reusable.

Then keep as much of the non-UI specific code as you can in a separate class library (or libraries); this will allow further re-use - for a different UI such as a WPF Custom Control Library.

As far as how the code is structured, MVC (as Arseny pointed out) is definitely an option.

Make good use of interfaces so that it's easy to integrate with.

Adrian K