Can a Value object (Transfer object pattern) and persistance object have "USING" relationship ?
That is ValueObject's overloaded constructor will take persistance object as parameter and get the details of persistance object and set the details to its member variables.
My question here is , is it a correct design ? or shoud i use any static method in ValueObject to give a instance of valueobject with the details or an external method (out of value object ) which will create a value object with details from persistance object.
If I were to design an application with Value Objects and Persistence Objects in an EJB environment which uses component based architecture, then I would not have such kind of Constructor in my ValueObject.
If you have such constructor or method in the value object (persistence object as a parameter) then you are coupling your value object to the persistence object. I would infact have my value object (serializable) and have it populated using a Utility class(with static methods) on the server side which can populate value object from the persistence object and vice versa.
So this value object can be used in your web layer as well as EJB layer without having the class definition to be dependant on the Persistence Class def.