views:

88

answers:

2

Is what I'm doing below a common design pattern? If so, what's the name?

I have a complex object that has "simple" fields like Strings and lists of Strings, as well as other complex objects. I want to add instances of this object to a JMS message queue, which means they need to be Serializable. I don't want to make the entire object graph Serializable, so I've chosen instead to make "Descriptor" objects that contain the necessary information to build the complex objects and "Builder" objects that can create the objects. Now, I serialize the "Descriptor" object and add it to the queue. When the object is dequeued, it is built into a full-fledged object using the "Builder".

An important note to make is that the objects are jobs that are run on other systems. The message queue is one way and serialization only happens at the beginning of the lifecycle of the job.

+4  A: 

To me this sounds like you implemented (part of) the Memento pattern.

Péter Török
+5  A: 

The most similar pattern to the one you implemented seems the Memento pattern.

In that case it's used to store the state of an object into a Memento object while anything can modify the original object and allows you to restore the old state by using the Memento as a "previous state" of your object.

In your case you don't need to store a snapshot of the object to modify the original one but just as a lightweight version of the serializable value of itself so it's not exactly the same things but quite similar.

Jack
Thanks for the answer and short explanation.
scompt.com