lundi 2 mars 2015

supporting new formates to export data. how to extand the existing classes

I have an export class Export which get a List of Object IDs as Arguments. It reads Data from Database against supplied IDs and creates one XML file per Object.


After creating all file these files are added to ZIP and are transfered to client per ftp.


The clients have different requirements, so per client the XML file may look different. So I am using this Export class as a factory which instantiates a class depending on client.


Like these client specific class look like ExportClient1,ExportClient2, ExportClient3


These classes contain method which formate the nodes according to clients requirements. For example the class have methods like writeImageNodes, writeTextNodes, writeAttributeNodes, writeRootNode,....


But these classes generate only XML nodes.


Now I am facing a new sitution, that a client needs the same data not only in XML but also in JSON and HTML


Should I change the Client specific classes to support different formates? and client specific classes should be used again as Factory classes to return XML,JSON or HTML specific components?


Aucun commentaire:

Enregistrer un commentaire