views:

448

answers:

3

Hi,

I'm stumped, I have a task where I have to take some markup (json format, not that it really matters) and parse it into an object model. We already have a domain model, its just a matter of running through the markup and creating the relevant objects.

It's not really suitable for the composite pattern as the objects being created are not similar. Also the markup is not that huge and only goes three levels deep so I'm more interested in an organisational pattern than raw speed. I would really like to achieve the following:

  • Avoid a monster method with lots of nested loops
  • Easy to add new tags/objects in the future
  • Clean easy to read code for the next person who has to modify it

Any suggestions on possible patterns that would be suitable for this? Feel free to give examples in any language, if so inclined.

Regards,

Chris

edit: Here's an example of the markup - link text

A: 

Can you give a simple example of the markup?

Glenn
I've edited the question to add a link
ChrisInCambo
+2  A: 
Rutesh Makhijani
A: 

Have a look at following link - it covers some design patterns - not all are applicable to you but I guess Command, Collecting Parameter and Pluggable Selector can be put to use.

http://junit.sourceforge.net/doc/cookstour/cookstour.htm

Nilesh