mercredi 27 juillet 2016

Design pattern to accommodate two different ways of handling a Winform's functions

I have a WinForm that I have used to build and test an email newsletter. This form contains a number of methods and events.

I am now adding a new feature to my program to allow split testing (A/X Test) and therefore creating up to 4 different newsletters for a campaign.

Therefore I'd like to extend my form to accommodate both normal newsletters and A/X newsletters. I'm going to add two different modes to my form. Something like:

private enum CampaignMode { Normal, AxTest };

They will be very similar in appearance, except a number of controls' visibility will change.

Apart from that, almost all methods and events will have two separate ways of handling.

What design pattern should I use so that I don't have to create a new separate form?

For simplicity, let's say my form has the following methods:

  1. Constructor: probably receiving the EditMode as a parameter
  2. Load
  3. Create: Button click event
  4. SetControlViews: Based on EditMode set the visibility of controls
  5. MethodA: Specific to Normal mode
  6. MethodB: Specific to AxTest mode

Aucun commentaire:

Enregistrer un commentaire