vendredi 31 août 2018

Which design pattern to serialise object Builder vs Visitor ?

I am trying to learn OOPS by examples. So I try to implement a object serialiser.The object is same but it can be serialised to either XML, JSON etc. I see two types of suggestions out there.

In this blog, they say we can use visitor/double dispatch to serialise objects.

http://codebetter.com/jeremymiller/2007/10/31/be-not-afraid-of-the-visitor-the-big-bad-composite-or-their-little-friend-double-dispatch/

But, by definition we are building a serialised object from a complex object, so it make sense to create a XMLBuilder and JSONBuilder.

Now, which is the right way to do it ?

Aucun commentaire:

Enregistrer un commentaire