views:

34

answers:

1

I have a composite object that was generated from an xml schema that I need to populate with data from a database.

The generated code doesn't enforce the schema's rules regarding required elements, max occurances, etc. I'd like to create a class (or collection of classes) to help fill in the composite object and ensure when its serialized the resulting xml will validate against the schema.

I've looked into the various creational design patterns and the Builder Pattern seems like it might work for this but having never used it I'm just not sure.

Is the Builder pattern the best way or am I off track? Is there a better way to go about this?

A: 

the short answer is yes, builder sounds like the most appropriate way to go with.

but the reality is that there's no REAL wrong way here. anything composite, builder, factory will all do the trick. I would start with something like builder (or maybe factory, but thats a personal preference) and maybe it'll evolve into a slightly modified pattern, depending on your use case.

patterns are just starting points, nothing more :)

Oren Mazor