I have an ObjectA whose property values will always be assigned to another object's (ObjectB) properites. What I have been doing is to have a service class instantiate the receiveing ObjectB and then assign the values to the new object from ObjectA. Should I instead be sending the entire objectA directly to Object B in a setter parameter or other method? What are best practices here if any?
EDIT: In a Service class:
public AssignValues (objectA)
{
ObjectB objectB= new ObjectB();
objectB.prop1= ObjectA.prop1;
objectB.prop2= ObjectA.prop2;
}
OR
public AssignValues(objectA)
{
ObjectB objectB= new ObjectB();
objectB.SetValuesFromObjectA= objectA;
}
OR
public AssignValues(objectA)
{
ObjectB objectB= new ObjectB();
objectB.SetValuesFromObjectA(objectA);
}
OR
public AssignValue(objectA)
{
ObjectB objectB= new ObjectB(objectA);
}