mardi 27 janvier 2015

Factory pattern with a class that can has different class sub types

I have data from multiple organisations (police, fire, office) that need output in different formats.


To achieve this, I defined the following, (this is a little simplified):


Transaction class with a a) "Success" indicator - Boolean b) "Type of department"- String or Enum c) A class which can be Police, Fire or Office (My question is on this as you will see).


I intend to use a Factory to return an appropriate Transaction object with the appropriate data (Transaction class with Police, Fire or Office data within it) and then pass the returned object to a Strategy pattern which determines the file format each one needs.


My problem is in the definition of the Transaction object.


1 - What type does "c)" need to be? The data for each org differs, there are no common members, I am unable to define a common class for all.


2 - Is the overall design appropriate?


Note: Intended language is c#


Aucun commentaire:

Enregistrer un commentaire