I am writing a service which can receive input messages in different formats like json, xml, csv etc. Though messages are in different format but data is similar in all of them. Which design pattern should i use to achieve following:
Thanks, Suraj
At first sight, I would say the Strategy pattern.
Make an abstract class (e.g. InputMessage), and derive strategies for json, xml etc. For a new type of input messages, only a new strategy can be derived from InputMessage.
You can use operations for converting to/from the generic format (these will differ for each strategy).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With