I am about to implement a document generator. I am insisting on following the Open-Closed Principle, what brings me some trouble. The requirements are as follows:
- there will be multiple document types (i.e. agreement, power of attorney)
- there will be multiple document formats (i.e. XML, JSON, HTML, PDF)
- each document type requires different set of data to be present on the document (i.e. client details, plenipotent details)
Due to my choice of following Open-Closed Principle, I would strongly like to avoid using switch statements. That means I need to introduce some abstractions and implementations for particular types of documents and types of formats.
Is it necessary to provide m x n class implementations, where m is the number of document types and n is the number of document formats? I feel that this is wrong way of doing it. Could you, please, give me some hints how to design such document generator properly?
Aucun commentaire:
Enregistrer un commentaire