mercredi 25 novembre 2015

Multi-format file conversion design pattern

In the past, I tried two times implementing a multi format converter. One was a Markup converter which should be able to convert GitHub, StackOverflow, MoinMoin, MediaWiki etc. The other is a photobook converter which currently converts ifolor to scribus but should support at least two more photo book formats plus pdf.

The problem is always the same: Different formats have different features. For example: MediaWiki and MoinMoin have different understandings of Macros while most other Markup languages don't support macros. Or ifolor had some border formats which were hard to implement in scribus and don't look nice.

I don't like the idea of implementing direct converters for every possible combination (for 4 formats this are 12 converters with a lot of redundancy). I started with a 'superset data structure' which contains all the features of all formats as a link between import and export filters of the given formats, but I wonder if there is a Best practice way to do such a thing or a something like a Design Pattern which could be helpful to know about, for example an architecture where import and export directly communicate without a 'super format'?

Well, the two projects are currently suspended because of a lack of time (and demand) but I'm willing to learn how I can do it better next time. The photobook did its job for my personal book and will probably be continued soon. Its code is on GitHub.

Aucun commentaire:

Enregistrer un commentaire