Currently I have an assignment, topic of which is "design patterns and their usage in real world applications (Java language)". My goal is to create a simple JSON to XML compiler using at least 7 design patterns. I have studied design patterns well enough to understand most of them, but when it comes to practical realization there are some troubles implementing the system.
What I tried: At first I had ideas about creating JSON structure using Composite design pattern like this: The same structure with XML: XMLEntity
, XMLObject
, XMLArray
. Then I would create something like XMLWriter
and use State design pattern to appropriately write elements in the document. And then create a class which accepts JSONEntity
and returns XMLEntity
(Conversion is done using XMLWriter
). But in the process I got confused by tree-like structure of the pattern and now am not sure whether it is appropriate here at all. I think both JSONEntity
and XMLEntity
should be represented, so that one object contains all other child objects. And when I need to convert it to JSON - the process could be recursive. But, again, I am confused whether it is possible to do so using Composite pattern.
Any ideas on where to start and which patterns to use in implementation are really welcome.
Aucun commentaire:
Enregistrer un commentaire